Generates a checkbox field
@param  array $options
@param  string $currentValue (Optional)
@return string
196622
protected function generateCheckbox($options, $currentValue = null)
    {
        $hidden = sprintf('<input type="hidden" name="%s" value="0">', $options['name']);
        $chk = sprintf('<input %s %s>', $this->arrayToHtmlAttributes($options), $options['value'] == $currentValue ? ' checked="checked"' : '');
        return $hidden . $chk;
    }
1272102
public function checkbox(string $name, array $options = []): FieldTypeInterface
    {
        return (new CheckboxType($name))
            ->setLocale($this->app->getLocale())
            ->setViewFactory($this->viewFactory)
            ->setOptions($options);
    }
505288
protected function renderSelectCheckbox($items, $selectedValues)
    {
        $parameterArray = [
            'fieldChangeFunc' => [],
            'itemFormElName' => $this->formElementName,
            'itemFormElValue' => $selectedValues,
            'fieldConf' => ['config' => ['items' => $items]],
            'fieldTSConfig' => ['noMatchingValue_label' => '']
        ];

        $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
        $options = [
            'renderType' => 'selectCheckBox', 'table' => 'tx_solr_classes_backend_indexingconfigurationselector',
            'fieldName' => 'additionalFields', 'databaseRow' => [], 'parameterArray' => $parameterArray
        ];
        $options['parameterArray']['fieldConf']['config']['items'] = $items;
        $options['parameterArray']['fieldTSConfig']['noMatchingValue_label'] = '';

        $selectCheckboxResult = $nodeFactory->create($options)->render();
        $formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
        $formResultCompiler->mergeResult($selectCheckboxResult);

        $formHtml = isset($selectCheckboxResult['html']) ? $selectCheckboxResult['html'] : '';
        $content = $formResultCompiler->addCssFiles() . $formHtml . $formResultCompiler->printNeededJSFunctions();

        return $content;
    }
516575
function SetCheckboxAttribute($optValue, $attribute, $value) {
        if (!isset($this->fieldAttributes[$optValue])) {
            $this->fieldAttributes[$optValue] = array();
        }
        $this->fieldAttributes[$optValue][$attribute] = $value;
    }
834280
public function checkbox($name, $value = 1, $checked = null, $options = array())
    {
        return $this->checkable('checkbox', $name, $value, $checked, $options);
    }
459283
protected function _render_checkbox($data, $current_value)
    {
        if (isset($data['name'])) {
            $name = $data['name'];
        } else {
            throw new MissingFieldException('name');
        }

        if (isset($data['values'])) {
            $values = $data['values'];
        } else {
            throw new MissingFieldException('values');
        }

        $r = PHP_EOL;
        /** @noinspection ForeachSourceInspection */
        foreach ($values as $value => $label) {
            $checked = is_array($current_value) && in_array($value, $current_value, false);
            $r .= '  <label><input type="checkbox"'
                . " name=\"{$name}[]\"  value=\"$value\" "
                . ($checked ? 'checked="checked"' : '')
                . '/><span>' . htmlspecialchars($label) . '</span></label>' . PHP_EOL;
        }

        return $r;
    }
512558
protected function generateCheckboxByGroup($id, $label, $name, $checked, array $options)
    {
        $identifier = \sprintf('%s_%s', $name, $id);
        $key = \sprintf('%s[]', $name);
        $active = \in_array($id, (array) $checked);

        $options['id'] = $identifier;

        $control = $this->checkbox($key, $id, $active, $options);

        $label = $this->label($identifier, $label);

        return \implode(' ', [$control, $label]);
    }
509203
public function calculateFieldInfo($currentValue, array $fieldData)
    {
        if (! $currentValue) {
            return $currentValue;
        }

        // Display nice
        $sql = $this->_sql . "WHERE grr_id = ?";
        $row = $this->db->fetchRow($sql, $currentValue);

        if ($row && isset($row['name'])) {
            return $row['name'];
        }

        return $currentValue;
    }
1356570
public function checkboxElement($name, $label = null, $value = 1, $checked = null, $inline = false, array $options = [])
    {
        $label = $label === false ? null : $this->getLabelTitle($label, $name);

        $labelOptions = $inline ? ['class' => 'checkbox-inline'] : [];
        $inputElement = $this->form->checkbox($name, $value, $checked, $options);
        $labelElement = '<label ' . $this->html->attributes($labelOptions) . '>' . $inputElement . $label . '</label>';

        return $inline ? $labelElement : '<div class="checkbox">' . $labelElement . '</div>';
    }
717398
public function generateSelectElement(array $options = array(), array $attributes = array(), $selectedValue = "", $templateToBeRendered = 'html_element_template')
    {
        $_options_html = "";

        foreach($options as $_option => $_val)
        {
            $_attributes = array("value" => $_val);

            if($_val == $selectedValue) {
                $_attributes['selected'] = "true";
            }

            $_options_html .= $this->generateElement(
                'option',
                $_attributes,
                $_val
            );
        }

        return $this->generateElement('select', $attributes, $_options_html, true, $templateToBeRendered);
    }
664799
protected function buildCheckbox()
    {
        /*
        checkbox:
            if option(s) passed via options array, checkbox assumed to be a "checkbox group"
                each option may contain value and attributes
                may also pass values array to specify initially checked values
            a single checkbox may be specified by setting
                label the checkbox's label
                value (the value attribute)
                checked (boolean - whether or not initially checked)
        */
        if (\count($this->props['options']) > 1) {
            if (\substr($this->props['attribs']['name'], -2) !== '[]') {
                $this->props['attribs']['name'] .= '[]';
            }
        }
        if ($this->props['useFieldset'] === 'auto') {
            $this->props['useFieldset'] = \count($this->props['options']) > 1 || $this->props['label'];
        }
        if ($this->props['useFieldset']) {
            $this->props['template'] = \preg_replace('#^<div([^>]*)>(.+)</div>$#s', '<fieldset$1>$2</fieldset>', $this->props['template']);
            $this->props['template'] = \preg_replace('#<label([^>]*)>(.+)</label>#s', '<legend>$2</legend>', $this->props['template']);
        }
        $attribStrings = $this->buildAttribStrings($this->props);
        $props = \array_merge($this->props, $attribStrings);
        $props['input'] = $this->buildCheckboxRadioGroup();
        if ($this->props['tagOnly']) {
            return $this->props;
        } else {
            return Str::quickTemp($props['template'], $props);
        }
    }
881761
private static function selectOptions(
        array $options = [],
        $actualValue = '',
        $multiple = false
    ) {
        $option = '';
        foreach ($options as $value => $label) {
            if (is_array($label)) {
                $option .= '<optgroup label="'. $value .'">';
                $option .= self::selectOptions($label, $actualValue, $multiple);
                $option .= '</optgroup>';
            } else {
                $selected = (!empty($value) && (
                    ($multiple === true && in_array($value, $actualValue)) ||
                    ($multiple === false && $value == $actualValue)
                )) ? ' selected' : '';
                $option .= '<option value="'. $value .'"'. $selected .'>'
                    . $label .'</option>';
            }
        }
        return $option;
    }
845864
protected function generateTextarea($options, $currentValue = null)
    {
        $value = is_null($currentValue) ? $options['value'] : $currentValue;

        unset($options['value']);
        unset($options["type"]);

        return sprintf('<textarea %s>%s</textarea>', $this->arrayToHtmlAttributes($options), stripslashes($value));
    }
683440
public function calculateFieldInfo($currentValue, array $fieldData)
    {
        if (! $currentValue) {
            return $currentValue;
        }

        $agenda      = $this->loader->getAgenda();
        $appointment = $agenda->getAppointment($currentValue);

        if ($appointment && $appointment->isActive()) {
            $time = $appointment->getAdmissionTime();

            if ($time) {
                return $time->toString($this->appointmentTimeFormat);
            }
        }

        return null;
    }
244882
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(!$exists) {
            return false;
        }
        
        if(!\is_array($value)) {
            return 'formvalidator_make_array';
        }
        
        if(!empty($options)) {
            foreach($value as $val) {
                $type = \gettype($val);
                if($type === 'double') {
                    $type = 'float'; // @codeCoverageIgnore
                }
                
                if($type !== $options) {
                    return array('formvalidator_make_array_subtype', array('{0}' => $options));
                }
            }
        }
        
        return true;
    }
843302
protected function getFieldId($optionValue = null)
    {
        if (!is_null($optionValue)) {
            return sprintf('%s_%s', $this->name, $this->cleanValue($optionValue));
        }

        return $this->name;
    }
486888
protected function createCheckbox($name, $options)
    {
        $box = new Checkbox($name, $options);
        $box->setAttribute('checked', true)
            ->setAttribute(
                'id',
                preg_replace(
                    array('~\[~', '~\]~', '~--+~', '~-$~'),
                    array('-', '', '-', ''),
                    $name
                )
            );

        return $box;
    }