addCriticalStylesheet('css/modules/form-element-rating.css'); $doc->addScript('js/lib/form/element/rating.js'); $multiOptions = (isset($attribs['options']) && is_array($attribs['options'])) ? $attribs['options'] : []; $options = [ 'multiOptions' => $this->_getMultiOptionsForJs($attribs['id'], $multiOptions), 'elementId' => $attribs['id'], ]; $doc->addInitObject('lib.form.element.Rating', [$options]); $radioHelper = new Zend_View_Helper_FormRadio(); $radioHelper->setView($this->view); if (array_key_exists('options', $attribs)) { unset($attribs['options']); } if (array_key_exists('listsep', $attribs)) { unset($attribs['listsep']); } $xhtml = $radioHelper->formRadio($name, $value, $attribs, $multiOptions, ''); return $xhtml; } protected function _getMultiOptionsForJs($id, $options) { $result = []; foreach ($options as $value => $label) { $result[] = ['id' => $id . '-' . $value, 'value' => $value]; } return $result; } }