input.select.php
Поле «Раскрывающийся список»
Вызывается из:
Смотрите описание Cms\Root\Form\Field\Select
Исходный код
<?php
$attributes = $Field->getInputAttributes(array(
'grid-margin' => $Field->getInputMargin(),
'grid-width' => $Field->getInputWidth(),
'name' => $Field->name,
'placeholder' => strval($Field->placeholder) !== '' ? htmlspecialchars($Field->placeholder) : null,
'required' => $Field->required ? '' : null,
'readonly' => $Field->readonly ? '' : null,
'disabled' => $Field->disabled ? '' : null,
'class' => 'field-input select',
'id' => $Field->id('-input'),
'tabindex' => $Field->readonly ? '-1' : null,
));
print '<select';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
if (is_array($Field->optionList) && !empty($Field->optionList)) {
$value = $Field->stringValue();
if (!isset($Field->options[''])) {
if (strval($Field->placeholder) !== '') {
print "\n" . '<option value="" data-placeholder="' . htmlspecialchars($Field->placeholder) . '">' . htmlspecialchars($Field->placeholder) . '</option>';
} else {
print "\n" . '<option value=""> </option>';
}
}
foreach ($Field->optionList as $option) {
if ($option['isGroup']) {
print "\n" . '<optgroup label="' . $Field->v($option['label']) . '">';
foreach ($option['optionList'] as $option) {
$optionValue = $option['value'];
$optionLabel = $option['label'];
print "\n" . '<option value="' . $Field->v($optionValue) . '"' . ($optionValue === $value ? ' selected=""' : '') . '>' . $Field->v($optionLabel) . '</option>';
}
print "\n" . '</optgroup>';
} else {
$optionValue = $option['value'];
$optionLabel = $option['label'];
if ($optionValue === '') {
if ($optionLabel === null || $optionLabel === false || $optionLabel === '-') continue;
}
print "\n" . '<option value="' . $Field->v($optionValue) . '"' . (strval($optionValue) === $value ? ' selected=""' : '') . '>' . $Field->v($optionLabel) . '</option>';
}
}
} elseif (strval($Field->placeholder) !== '') {
print "\n" . '<option value="" data-placeholder="' . htmlspecialchars($Field->placeholder) . '">' . htmlspecialchars($Field->placeholder) . '</option>';
} else {
print "\n" . '<option value=""> </option>';
}
print "\n" . '</select>';
?>