input.radio.php
Поле «Переключатель»
Вызывается из:
Смотрите описание Cms\Root\Form\Field\Radio
Исходный код
<?php
$attributes = $Field->getFieldInputAttributes(array(
'grid-margin' => $Field->getInputMargin(),
'grid-width' => $Field->getInputWidth(),
'class' => 'field-input field-input--' . $Field->type,
'id' => $Field->id('-input'),
'data-name' => $Field->name,
));
print '<span';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
$attributes = $Field->getInputAttributes(array(
'type' => 'radio',
'name' => $Field->name,
'placeholder' => strval($Field->placeholder) !== '' ? htmlspecialchars($Field->placeholder) : null,
'required' => $Field->required ? '' : null,
'readonly' => $Field->readonly ? '' : null,
'disabled' => $Field->disabled ? '' : null,
'class' => 'input--radio',
'onclick' => $Field->readonly ? 'return false' : null,
));
if (is_array($Field->options) && !empty($Field->options)) {
$value = $Field->stringValue();
foreach ($Field->options as $optionValue => $optionLabel) {
$attributes['value'] = $Field->v($optionValue);
$attributes['checked'] = strval($optionValue) === $value ? '' : null;
print '<label class="input-label input-label--radio">';
print '<input';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
print '<span class="label-text">' . $optionLabel . '</span>';
print '</label>';
}
} else {
$attributes['value'] = '';
print '<label class="input-label input-label--radio">';
print '<input';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
print '<span class="label-text"></span>';
print '</label>';
}
print '</span>';
?>