Advertisement
Guest User

Untitled

a guest
May 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.16 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Form to proceed to printing partial application
  4.  *
  5.  * @author zburnham
  6.  * @version 0.01
  7.  */
  8. class Efi_Form_Nmarp_ContinueToExtendedInfo extends Zend_Form
  9. {
  10.     /**
  11.      * Registration code.
  12.      *
  13.      * @var string
  14.      */
  15.     protected $code;
  16.  
  17.     /**
  18.      * Target of form (action)
  19.      *
  20.      * @var string
  21.      */
  22.     protected $actionTarget;
  23.    
  24.     /**
  25.      * Value for submit button
  26.      *
  27.      * @var string
  28.      */
  29.     protected $submitValue;
  30.    
  31.     /**
  32.      * Namespace to differentiate different instances of same form
  33.      *
  34.      * @var Zend_Session_Namespace
  35.      */
  36.     protected $csrfNamespace;
  37.    
  38.     /**
  39.      * Initialize form.
  40.      *
  41.      */
  42.    
  43.     public function __construct($code = NULL, $action = NULL, $submitValue = NULL, Zend_Session_Namespace $csrfNamespace = NULL)
  44.     {
  45.         $this->setCode($code);
  46.         $this->setAction($action);
  47.         $this->setSubmitValue($submitValue);
  48.         $this->setCsrfNamespace($csrfNamespace);
  49.         parent::__construct();
  50.     }
  51.    
  52.     public function init()
  53.     {
  54.         $this->setMethod('POST');
  55.        
  56.         /**
  57.          * code element
  58.          */
  59.         $code = new Zend_Form_Element_Hidden('code');
  60.         $code->addFilter(new Zend_Filter_StripTags())
  61.              ->addValidator(new Zend_Validate_StringLength(8,8))
  62.              ->addValidator(new Zend_Validate_Alnum())
  63.              ->setValue($this->getCode())
  64.              ->setLabel("Code:")
  65.              ->clearDecorators()
  66.              ->addDecorator('ViewHelper')
  67.              ->setRequired();
  68.         $this->addElement($code);
  69.        
  70.         /**
  71.          * CSRF protection
  72.          */
  73.         $csrf = new Zend_Form_Element_Hash('csrf');
  74.         $csrf->addFilter(new Zend_Filter_StripTags())
  75.              ->addFilter(new Zend_Filter_Alnum())
  76.              ->setRequired()
  77.              ->setSession($this->getCsrfNamespace())
  78.              ->clearDecorators()
  79.              ->addDecorator('ViewHelper')
  80.              ->setIgnore(TRUE);
  81.         $this->addElement($csrf);
  82.        
  83.         /**
  84.          * submit element
  85.          */
  86.         $submit = new Zend_Form_Element_Submit('submit');
  87.         $submit->addFilter(new Zend_Filter_StripTags())
  88.                ->addFilter(new Zend_Filter_Alnum())
  89.                ->setRequired()
  90.                ->setValue($this->getSubmitValue())
  91.                ->setLabel($this->getSubmitValue())
  92.                ->clearDecorators()
  93.                ->addDecorator('ViewHelper')
  94.                ->addDecorator('Errors')
  95.                ->addDecorator('Description', array('tag' => 'p', 'class' => 'description'))
  96.                ->addDecorator('HtmlTag', array('tag' => 'td',
  97.                                                'id'  => $submit->getName() . '-element'));
  98.         $this->addElement($submit);
  99.     }
  100.    
  101.     /**
  102.      * @return string
  103.      */
  104.     public function getCode()
  105.     {
  106.         return $this->code;
  107.     }
  108.  
  109.     /**
  110.      * @param string $registrationCode
  111.      * @return Efi_Form_Nmarp_PrintPartialApplication
  112.      */
  113.     public function setCode($code)
  114.     {
  115.         $this->code = $code;
  116.         return $this;
  117.     }
  118.  
  119.     /**
  120.      * @return string
  121.      */
  122.     public function getActionTarget()
  123.     {
  124.         return $this->actionTarget;
  125.     }
  126.  
  127.     /**
  128.      * @param string $actionTarget
  129.      * return Efi_Form_Nmarp_ContinueToExtendedInfo
  130.      */
  131.     public function setActionTarget($actionTarget)
  132.     {
  133.         $this->actionTarget = $actionTarget;
  134.         return $this;
  135.     }
  136.  
  137.     /**
  138.      * @return string
  139.      */
  140.     public function getSubmitValue()
  141.     {
  142.         return $this->submitValue;
  143.     }
  144.  
  145.     /**
  146.      * @param string $submitValue
  147.      * @return Efi_Form_Nmarp_ContinueToExtendedInfo
  148.      */
  149.     public function setSubmitValue($submitValue)
  150.     {
  151.         $this->submitValue = $submitValue;
  152.         return $this;
  153.     }
  154.  
  155.     /**
  156.      * @return Zend_Session_Namespace
  157.      */
  158.     public function getCsrfNamespace()
  159.     {
  160.         return $this->csrfNamespace;
  161.     }
  162.  
  163.     /**
  164.      * @param Zend_Session_Namespace $csrfNamespace
  165.      * @return Efi_Form_Nmarp_ContinueToExtendedInfo
  166.      */
  167.     public function setCsrfNamespace($csrfNamespace)
  168.     {
  169.         $this->csrfNamespace = $csrfNamespace;
  170.         return $this;
  171.     }
  172. }
  173.  
  174. Controller code:
  175.             $printPartialApplicationForm = new Efi_Form_Nmarp_ContinueToExtendedInfo($newCode, '/' . $this->getOriginalControllerName() . '/printpartial', "Print Mail-In Application Now", new Zend_Session_Namespace('partial'));
  176.             $this->view->printPartialApplicationForm = $printPartialApplicationForm;
  177.            
  178.             $proceedToCompleteForm = new Efi_Form_Nmarp_ContinueToExtendedInfo($newCode, '/' . $this->getOriginalControllerName() . '/step4', 'Proceed to Complete Application Now', new Zend_Session_Namespace('full'));
  179.             $this->view->proceedToCompleteForm = $proceedToCompleteForm;
  180.  
  181. ...
  182.  
  183.            $continueToExtendedInfoValidationForm = new Efi_Form_Nmarp_ContinueToExtendedInfo(NULL, NULL, NULL, new Zend_Session_Namespace('partial'));
  184.             if ($continueToExtendedInfoValidationForm->isValid($post)){  etc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement