3 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
60 parent::initializeArguments();
62 'disabled',
'string',
'Specifies that the input element should be disabled when the page loads'
65 'errorClass',
'string',
'CSS class to set if there are errors for this view helper',
false,
'f3-form-error'
67 $this->
overrideArgument(
'value',
'string',
'Value of input tag. Required for checkboxes',
true);
80 public function render($checked = null, $multiple = null)
82 $this->tag->addAttribute(
'type',
'checkbox');
84 $nameAttribute = $this->
getName();
86 $propertyValue = null;
90 if ($checked === null && $propertyValue === null) {
94 if ($propertyValue instanceof \Traversable) {
95 $propertyValue = iterator_to_array($propertyValue);
97 if (is_array($propertyValue)) {
98 $propertyValue = array_map(array($this,
'convertToPlainValue'), $propertyValue);
99 if ($checked === null) {
100 $checked = in_array($valueAttribute, $propertyValue);
102 $nameAttribute .=
'[]';
103 }
elseif ($multiple ===
true) {
104 $nameAttribute .=
'[]';
105 }
elseif ($propertyValue !== null) {
106 $checked = (boolean) $propertyValue === (
boolean) $valueAttribute;
110 $this->tag->addAttribute(
'name', $nameAttribute);
111 $this->tag->addAttribute(
'value', $valueAttribute);
112 if ($checked ===
true) {
113 $this->tag->addAttribute(
'checked',
'checked');
118 return $hiddenField . $this->tag->render();