- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/internals/input.php
- Класс: BitrixSaleInternalsInputLocation
- Вызов: Location::getEditHtml
static function getEditHtml($name, array $input, $value = null)
{
$name = htmlspecialcharsbx($name);
$input['DISABLED'] ??= 'N';
if ($value === null && isset($input['VALUE']))
{
$value = $input['VALUE'];
}
$html = '';
if (isset($input['HIDDEN']) && ($input['HIDDEN'] === 'Y' || $input['HIDDEN'] === true))
{
$html .= static::getHiddenRecursive($name
, (isset($input['MULTIPLE']) && $input['MULTIPLE'] === 'Y') ? static::asMultiple($value) : static::asSingle($value)
, static::extractAttributes($input, array('DISABLED'=>''), array('FORM'=>1), false));
}
else
{
$selector = md5("location input selector $name");
$input["LOCATION_SELECTOR"] = $selector;
if ($onChange = $input['ONCHANGE'])
{
$functionName = 'OnLocationChange'.$selector;
$html .= "";
$input['JS_CALLBACK'] = $functionName;
}
else
{
$input['JS_CALLBACK'] = null;
}
if (isset($input['MULTIPLE']) && $input['MULTIPLE'] === 'Y')
{
$tag = isset($input['MULTITAG']) ? htmlspecialcharsbx($input['MULTITAG']) : static::MULTITAG;
[$startTag, $endTag] = $tag ? array("<$tag>", "$tag>") : array('', '');
$index = -1;
$values = static::asMultiple($value);
if (empty($value))
{
$values = array(null);
}
foreach ($values as $value)
$html .= $startTag
.static::getEditHtmlSingle($name.'['.(++$index).']', $input, $value)
.$endTag;
$replace = '##INPUT##NAME##';
if ($input['DISABLED'] !== 'Y') // TODO
$html .= static::getEditHtmlInsert($tag, $replace, $name
, static::getEditHtmlSingle($replace, $input, null)
, "var location = BX.locationSelectors['$selector'].spawn(container, {selectedItem: false, useSpawn: false});"
."location.clearSelected();"
//."location.focus();" // TODO
);
}
else
{
$html .= static::getEditHtmlSingle($name, $input, static::asSingle($value));
}
}
if (isset($input['ADDITIONAL_HIDDEN']) && $input['ADDITIONAL_HIDDEN'] === 'Y')
{
$html .= static::getHiddenRecursive($name
, (isset($input['MULTIPLE']) && $input['MULTIPLE'] === 'Y') ? static::asMultiple($value) : static::asSingle($value)
, static::extractAttributes($input, array(), array('FORM'=>1), false));
}
return $html;
}