getPaymentType(); 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' => $this->isPaymentRequired())); $this->addDisplayGroup(array('type'), 'typeGroup'); $this->_addServiceType('payment', $paymentType); } else { $this->addElement( 'radio', 'type', array( 'multiOptions' => $paymentTypes, 'required' => $this->isPaymentRequired() ) ); $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() { return \App\ECommerce\Checkout\Model::getPaymentTypes(); } 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; } }