'Select One'] + $this->_getCommittees(); $this->addElement( 'select', 'committeeId', [ 'label' => 'Committee', 'allowEmpty' => false, 'multioptions' => $options, 'decorators' => ['ViewHelper', 'Errors', ['HtmlTag', ['tag' => 'td']]], ] ); $options = ['' => 'Select One'] + $this->_getCommitteePositions(); $this->addElement( 'select', 'positionId', [ 'label' => 'Position', 'allowEmpty' => false, 'multioptions' => $options, 'decorators' => ['ViewHelper', 'Errors', ['HtmlTag', ['tag' => 'td']]], ] ); $this->addElement( 'CommitteeItemOptions', 'options', [ 'label' => 'Options', 'decorators' => ['ViewHelper', ['HtmlTag', ['tag' => 'td']]], ] ); return $this; } protected function _getCommittees() { return $this->_get4Select('Committee'); } protected function _getCommitteePositions() { return $this->_get4Select('CommitteePosition'); } public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return $this; } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('FormElements'); $this->addDecorator(['item-tr' => 'HtmlTag'], ['tag' => 'tr', 'class' => 'line-item item-row']); } return $this; } public function validateRequired($value, $context, $fieldName) { $dependentField = ($fieldName == 'committeeId') ? 'positionId' : 'committeeId'; if ('' == $value && '' != $context[$dependentField]) { return false; } return true; } public function initRender() { if ($this->getInitializedRender()) { return $this; } // ids fix $this->getDecorator('item-tr')->setOption('id', $this->getFullId() . '-row'); /** @var \Zend_Form_Element $element */ foreach ($this as $element) { $element->getDecorator('HtmlTag')->setOption('id', $element->getId() . '-element'); $element->getDecorator('HtmlTag')->setOption('class', $element->getName()); } return parent::initRender(); } }