_formDataFields) { $preparedData = array(); foreach ($this->_formDataFields as $groupName => $fields) { foreach ($fields as $field) { $dataField = $groupName . ucfirst($field); $fieldGroup = $groupName; switch ($groupName) { case 'payment': $fieldGroup = App_ECommerce_Checkout_View::PAYMENT_SECTION_DATA; break; case 'shipping': $fieldGroup = App_ECommerce_Checkout_View::SHIPPING_SECTION_DATA; break; default : break; } if (isset($data[$dataField])) { $preparedData[$fieldGroup][$field] = $data[$dataField]; } } } $section = App_ECommerce_Checkout_View::SHIPPING_SECTION_DATA; $shippingType = lcfirst($data['shippingName']); $preparedData[$section]['type'] = $shippingType; $method = $preparedData[$section]['type'] . 'Method'; $preparedData[$section][$shippingType][$method] = $data['shippingServiceCode']; $addressType = $preparedData[$section]['type'] . 'AddressType'; $preparedData[$section][$shippingType][$addressType] = $data['shippingAddressType']; $preparedData['id'] = $data['id']; $data = $preparedData; } return $this; } public function setFormDataFields(Qs_Form $form) { $dataFields = array(); $subforms = $form->getSubForms(); foreach ($subforms as $subform) { /** @var Qs_Form_SubForm $subform */ foreach ($subform->getElements() as $element) { /** @var Zend_Form_Element $element */ $subformName = $subform->getName(); switch ($subformName) { case App_ECommerce_Checkout_View::SHIPPING_SECTION_DATA: $subformName = 'shipping'; break; default : break; } $dataFields[$subformName][] = $element->getName(); } } $this->_formDataFields = $dataFields; return $this; } public function isValidTab($restAlias) { $restParams = explode('/', $restAlias); if (ctype_digit($restParams[1])) { $this->setPrimaryKey((int) $restParams[1]); $this->_initCart(); return $this->isValidPage(); } return false; } protected function _initCart() { $cartObj = CartObj::getInstance(); $cartObj->setPrimaryKey($cartObj->getCartIdByTransaction($this->_primaryKey)); $cartObj->getSessionCartObject()->id = $cartObj->getPrimaryKey(); return $this; } public function isValidPage() { $data = $this->getData(); $dataForm = new App_ECommerce_Order_Admin_Customer_Form_New(); $this->setFormDataFields($dataForm); $validatedData = array(); foreach ($this->_formDataFields as $groupName => $fields) { foreach ($fields as $field) { if ($dataForm->getSubForm($groupName)->getElement($field) instanceof Zend_Form_Element_Checkbox) { continue; } $dataField = $groupName . ucfirst($field); if (!empty($data[$dataField])) { $validatedData[$dataField] = $data[$dataField]; } } } $this->_formDataFields = null; return !empty($validatedData); } }