/** * Returns the HTML content for a checkbox group field * * @param string $formName Name of the form * @param string $fieldName Name of the field * @return string HTML content */ protected function renderCheckboxGroupField($formName, $fieldName) { if (empty($this->arguments['options'])) { return ''; } $options = $this->getOptions(); if (empty($options)) { $options = array('' => ''); } $icon = !empty($this->arguments['optionIcon']) ? $this->arguments['optionIcon'] : ''; $items = array(); $checkedItems = array(); foreach ($options as $value => $label) { $items[] = array($label, $value, $icon); if ($this->isChecked($value)) { $checkedItems[] = $value; } // Register the field name for each option for the token generation $this->registerFieldNameForFormTokenGeneration($fieldName . '[]'); } $setup = array('itemFormElValue' => implode(',', $checkedItems), 'itemFormElName' => $this->getName(), 'fieldChangeFunc' => array()); // Render field with default form engine $formEngine = $this->objectManager->create('TYPO3\\CMS\\Backend\\Form\\FormEngine'); $formEngine->formName = $formName; $content = $formEngine->getSingleField_typeSelect_checkbox('', '', array(), $setup, array(), $items, '%s'); unset($formEngine); return $content; }