getAuthData('approved') === 'y'; } protected function _initElements() { $paymentTypes = $this->getPaymentType(); $disable = false; if (!$this->_isApproved()) { $paymentTypes['po'] .= ' (Contact us for approval to pay via this method)'; $disable = ['po']; } if (count($paymentTypes) == 1) { $paymentType = current(array_keys($paymentTypes)); $paymentTitle = ucfirst(current($paymentTypes)); $this->addElement('static', $paymentType . 'Title', array('value' => $paymentTitle)); $this->addElement('hidden', 'type', array('value' => $paymentType, 'required' => true)); $this->addDisplayGroup(array('type'), 'typeGroup'); $this->_addServiceType('payment', $paymentType); } else { $this->addElement( 'radio', 'type', array( 'multiOptions' => $paymentTypes, 'required' => true, 'disable' => $disable, ) ); if (false !== $disable) { $this->getElement('type')->addValidator('InArray', true, array( 'haystack' => array_diff(array_keys($paymentTypes), $disable), 'messages' => [Zend_Validate_InArray::NOT_IN_ARRAY => 'Method not allowed'], )); } $this->addDisplayGroup(array('type'), 'typeGroup'); foreach (array_keys($paymentTypes) as $type) { $this->_addServiceType('payment', $type, array('class' => 'payment')); } } if (($paymentData = $this->_getData('servicePayment')) !== null) { foreach (array_keys($paymentTypes) as $type) { if (array_key_exists('type', $paymentData) && $paymentData['type'] == $type) { if (null !== ($group = $this->getDisplayGroup($type . 'Methods'))) { $group->setAttrib('class', 'payment'); } continue; } if (null !== ($group = $this->getDisplayGroup($type . 'Methods'))) { foreach ($group->getElements() as $element) { /** @var $element Zend_Form_Element */ $element->setRequired(false); } } } } return $this; } /** * Return type for payment * * @return array|bool */ public function getPaymentType() { $types = false; foreach ($this->_getConfig('payment') as $key => $type) { if (is_int($key)) { $title = ucfirst($type); } else { $title = $type; $type = $key; } $types[$type] = $title; } return $types; } public function reinitData($data) { if (array_key_exists('servicePayment', $data) && array_key_exists('type', $data['servicePayment'])) { if (null !== ($group = $this->getDisplayGroup($data['servicePayment']['type'] . 'Methods'))) { $group->setAttrib('class', 'payment'); } } return $this; } }