getPaymentType(); $this->addElement( 'radio', 'type', array( 'multiOptions' => $paymentTypes, 'required' => $this->isPaymentRequired() ) ); if (count($paymentTypes) == 1) { $paymentType = current(array_keys($paymentTypes)); $this->getElement('type')->setValue($paymentType); $this->getElement('type')->setAttrib('class', $this->getElement('type')->getAttrib('class') . ' hidden'); } $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; } }