public function init() { parent::init(); $this->setName('newPhoneNumberForm')->setAction('/register/contact/change-phone-number')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'Area')), 'Form'))->setMethod('post'); $id = new Zend_Form_Element_Hidden('id'); $id->addValidator('Int')->addFilter('StringTrim'); $this->addElement($id); }
public function addPhoneNumberAction() { // cria form if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getPost(); $form = new C3op_Form_PhoneNumberCreate(); $this->view->form = $form; if ($form->isValid($postData)) { $id = $form->process($postData); $this->_helper->getHelper('FlashMessenger')->addMessage('The record was successfully updated.'); $this->_redirect('/register/contact/success-create/?id=' . $id); } else { throw new C3op_Register_ContactException("Invalid data for phone number."); } } else { $contactId = $this->checkIdFromGet(); $contactHasPhone = $this->contactMapper->findById($contactId); $data = $this->_request->getParams(); $form = new C3op_Form_PhoneNumberCreate(); C3op_Util_FormFieldValueSetter::SetValueToFormField($form, 'contact', $contactId); $this->view->form = $form; $contactInfo = array('id' => $contactId, 'name' => $contactHasPhone->GetName()); $this->view->contactInfo = $contactInfo; } }