Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Form to proceed to printing partial application
- *
- * @author zburnham
- * @version 0.01
- */
- class Efi_Form_Nmarp_ContinueToExtendedInfo extends Zend_Form
- {
- /**
- * Registration code.
- *
- * @var string
- */
- protected $code;
- /**
- * Target of form (action)
- *
- * @var string
- */
- protected $actionTarget;
- /**
- * Value for submit button
- *
- * @var string
- */
- protected $submitValue;
- /**
- * Namespace to differentiate different instances of same form
- *
- * @var Zend_Session_Namespace
- */
- protected $csrfNamespace;
- /**
- * Initialize form.
- *
- */
- public function __construct($code = NULL, $action = NULL, $submitValue = NULL, Zend_Session_Namespace $csrfNamespace = NULL)
- {
- $this->setCode($code);
- $this->setAction($action);
- $this->setSubmitValue($submitValue);
- $this->setCsrfNamespace($csrfNamespace);
- parent::__construct();
- }
- public function init()
- {
- $this->setMethod('POST');
- /**
- * code element
- */
- $code = new Zend_Form_Element_Hidden('code');
- $code->addFilter(new Zend_Filter_StripTags())
- ->addValidator(new Zend_Validate_StringLength(8,8))
- ->addValidator(new Zend_Validate_Alnum())
- ->setValue($this->getCode())
- ->setLabel("Code:")
- ->clearDecorators()
- ->addDecorator('ViewHelper')
- ->setRequired();
- $this->addElement($code);
- /**
- * CSRF protection
- */
- $csrf = new Zend_Form_Element_Hash('csrf');
- $csrf->addFilter(new Zend_Filter_StripTags())
- ->addFilter(new Zend_Filter_Alnum())
- ->setRequired()
- ->setSession($this->getCsrfNamespace())
- ->clearDecorators()
- ->addDecorator('ViewHelper')
- ->setIgnore(TRUE);
- $this->addElement($csrf);
- /**
- * submit element
- */
- $submit = new Zend_Form_Element_Submit('submit');
- $submit->addFilter(new Zend_Filter_StripTags())
- ->addFilter(new Zend_Filter_Alnum())
- ->setRequired()
- ->setValue($this->getSubmitValue())
- ->setLabel($this->getSubmitValue())
- ->clearDecorators()
- ->addDecorator('ViewHelper')
- ->addDecorator('Errors')
- ->addDecorator('Description', array('tag' => 'p', 'class' => 'description'))
- ->addDecorator('HtmlTag', array('tag' => 'td',
- 'id' => $submit->getName() . '-element'));
- $this->addElement($submit);
- }
- /**
- * @return string
- */
- public function getCode()
- {
- return $this->code;
- }
- /**
- * @param string $registrationCode
- * @return Efi_Form_Nmarp_PrintPartialApplication
- */
- public function setCode($code)
- {
- $this->code = $code;
- return $this;
- }
- /**
- * @return string
- */
- public function getActionTarget()
- {
- return $this->actionTarget;
- }
- /**
- * @param string $actionTarget
- * return Efi_Form_Nmarp_ContinueToExtendedInfo
- */
- public function setActionTarget($actionTarget)
- {
- $this->actionTarget = $actionTarget;
- return $this;
- }
- /**
- * @return string
- */
- public function getSubmitValue()
- {
- return $this->submitValue;
- }
- /**
- * @param string $submitValue
- * @return Efi_Form_Nmarp_ContinueToExtendedInfo
- */
- public function setSubmitValue($submitValue)
- {
- $this->submitValue = $submitValue;
- return $this;
- }
- /**
- * @return Zend_Session_Namespace
- */
- public function getCsrfNamespace()
- {
- return $this->csrfNamespace;
- }
- /**
- * @param Zend_Session_Namespace $csrfNamespace
- * @return Efi_Form_Nmarp_ContinueToExtendedInfo
- */
- public function setCsrfNamespace($csrfNamespace)
- {
- $this->csrfNamespace = $csrfNamespace;
- return $this;
- }
- }
- Controller code:
- $printPartialApplicationForm = new Efi_Form_Nmarp_ContinueToExtendedInfo($newCode, '/' . $this->getOriginalControllerName() . '/printpartial', "Print Mail-In Application Now", new Zend_Session_Namespace('partial'));
- $this->view->printPartialApplicationForm = $printPartialApplicationForm;
- $proceedToCompleteForm = new Efi_Form_Nmarp_ContinueToExtendedInfo($newCode, '/' . $this->getOriginalControllerName() . '/step4', 'Proceed to Complete Application Now', new Zend_Session_Namespace('full'));
- $this->view->proceedToCompleteForm = $proceedToCompleteForm;
- ...
- $continueToExtendedInfoValidationForm = new Efi_Form_Nmarp_ContinueToExtendedInfo(NULL, NULL, NULL, new Zend_Session_Namespace('partial'));
- if ($continueToExtendedInfoValidationForm->isValid($post)){ etc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement