Contao\FormCheckBox::generate PHP Method

generate() public method

Generate the widget and return it as string
public generate ( ) : string
return string The widget markup
    public function generate()
    {
        $strOptions = '';
        foreach ($this->arrOptions as $i => $arrOption) {
            $strOptions .= sprintf('<span><input type="checkbox" name="%s" id="opt_%s" class="checkbox" value="%s"%s%s%s <label id="lbl_%s" for="opt_%s">%s</label></span> ', $this->strName . (count($this->arrOptions) > 1 ? '[]' : ''), $this->strId . '_' . $i, $arrOption['value'], $this->isChecked($arrOption), $this->getAttributes(), $this->strTagEnding, $this->strId . '_' . $i, $this->strId . '_' . $i, $arrOption['label']);
        }
        if ($this->strLabel != '') {
            return sprintf('<fieldset id="ctrl_%s" class="checkbox_container%s"><legend>%s%s%s</legend>%s<input type="hidden" name="%s" value=""%s%s</fieldset>', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->mandatory ? '<span class="invisible">' . $GLOBALS['TL_LANG']['MSC']['mandatory'] . ' </span>' : '', $this->strLabel, $this->mandatory ? '<span class="mandatory">*</span>' : '', $this->strError, $this->strName, $this->strTagEnding, $strOptions);
        } else {
            return sprintf('<fieldset id="ctrl_%s" class="checkbox_container%s">%s<input type="hidden" name="%s" value=""%s%s</fieldset>', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->strError, $this->strName, $this->strTagEnding, $strOptions);
        }
    }