Пример #1
0
 /**
  * Create property subform
  *
  * @return void
  */
 public function init()
 {
     // Add address element
     $this->addElement('text', 'property_address', array('label' => 'Address', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the company address', 'notEmptyInvalid' => 'Please enter the company address'))))));
     // Add postcode element
     $this->addElement('text', 'property_postcode', array('label' => 'Postcode', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the company postcode', 'notEmptyInvalid' => 'Please enter the company postcode'))), array('Postcode'))));
     // Add managed element
     $this->addElement('select', 'property_managed', array('label' => 'Property let type', 'required' => true, 'multiOptions' => array('' => '--- Please select ---', '1' => 'Let Only', '2' => 'Managed', '3' => 'Rent Collect'), 'separator' => '', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select a property type', 'notEmptyInvalid' => 'Please select a valid property let type'))))));
     // Add managed element
     $this->addElement('select', 'how_rg_offered', array('label' => 'How is Rent Guarantee offered to your landlord', 'required' => true, 'multiOptions' => array('' => '--- Please select ---', '1' => 'Free of charge', '2' => 'Included in Management Fees', '3' => 'Separate charge for Rent Guarantee to the landlord', '4' => "I'm not purchasing Rent Guarantee"), 'separator' => '', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select a rent guarantee offer', 'notEmptyInvalid' => 'Please select a valid rent guarantee offer'))))));
     // Add total rent element
     $this->addElement('text', 'tenant_renttotal', array('label' => 'Total rent for this property (per month)', 'required' => true, 'attribs' => array('class' => 'currency'), 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the total rent', 'notEmptyInvalid' => 'Please enter the total rent'))), array('regex', true, array('pattern' => '/^\\d{1,}$/', 'messages' => 'Amount of total rent must contain at least one digit')), array('GreaterThan', true, array('min' => 0, 'messages' => 'Total rent must be above zero')))));
     // Add applicant share of rent element
     $this->addElement('text', 'tenant_rentshare', array('label' => 'Applicant share of rent (per month)', 'required' => true, 'attribs' => array('class' => 'currency'), 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the share of rent', 'notEmptyInvalid' => 'Please enter the share of rent'))), array('regex', true, array('pattern' => '/^\\d{1,}$/', 'messages' => 'Share of rent must contain at least one digit')), array('GreaterThan', true, array('min' => 0, 'messages' => 'Share of rent must be above zero')))));
     // Add tenancy term element
     $this->addElement('text', 'tenant_term', array('label' => 'Tenancy term (months)', 'required' => true, 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenancy term', 'notEmptyInvalid' => 'Please enter the tenancy term'))), array('regex', true, array('pattern' => '/^\\d{1,}$/', 'messages' => 'Tenancy term must contain at least one digit')), array('GreaterThan', true, array('min' => 0, 'messages' => 'Tenancy term must be above zero')))));
     // Add tenancy start date element
     $this->addElement('text', 'tenant_startdate', array('label' => 'Tenancy start date (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim')));
     $tenant_startdate = $this->getElement('tenant_startdate');
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 60 * 60 * 24 * 365);
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 60 * 60 * 24 * 365);
     $validator->setMessages(array('msgMinimum' => 'Tenancy start date too far in the past', 'msgMaximum' => 'Tenancy start date too far in the future'));
     $tenant_startdate->addValidator($validator, true);
     // Add number of tenants element
     $this->addElement('text', 'tenant_number', array('label' => 'Total number of tenants to be referenced for the property', 'required' => true, 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant amount', 'notEmptyInvalid' => 'Please enter the tenant amount'))), array('regex', true, array('pattern' => '/^\\d{1,}$/', 'messages' => 'Tenant amount must contain at least one digit')), array('GreaterThan', true, array('min' => 0, 'messages' => 'Tenant amount must be above zero')))));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'referencing/subforms/company-application-property.phtml'))));
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
Пример #2
0
 /**
  * Pull in the sub forms that comprise Portfolio Step 3
  *
  * @return void
  */
 public function init()
 {
     // Existing Insurer
     $this->addElement('text', 'target_premium', array('label' => '', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please let us know how much your renewal premium is', 'notEmptyInvalid' => 'Please let us know how much your renewal premium is'))))));
     // Existing Insurer
     $this->addElement('text', 'existing_insurer', array('label' => '', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please let us know the name of you existng insurer', 'notEmptyInvalid' => 'Please let us know the name of you existng insurer'))))));
     // Add next renewal date element
     $this->addElement('text', 'next_renwal_date', array('label' => '', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your renewal date', 'notEmptyInvalid' => 'Please enter a valid policy start date'))))));
     $next_renwal_date = $this->getElement('next_renwal_date');
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')));
     $validator->setMessages(array('msgMinimum' => 'Policy start date cannot be in the past'));
     $next_renwal_date->addValidator($validator, true);
     // Append additional styles for the datepicker
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $view->headLink()->appendStylesheet('/assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker.min.css', 'screen');
     // Append required JS files for the datepicker to function
     $view->headScript()->appendFile('/assets/vendor/jquery-date/js/date.js', 'text/javascript')->appendFile('/assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js', 'text/javascript')->appendFile('/assets/portfolio-insurance-quote/js/renewalDatePicker.js', 'text/javascript');
     // Add 'how did you hear about us?' element
     $this->addElement('select', 'how_hear', array('label' => '', 'required' => false, 'multiOptions' => array('' => 'Please Select', 'Letting Agent' => 'Letting Agent', 'Personal Recommendation' => 'Personal Recommendation', 'SMS' => 'SMS', 'Email' => 'Email', 'Letter' => 'Letter', 'Internet Location' => 'Internet Location', 'Publication' => 'Publication', 'Other' => 'Other'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select How did you heard about us', 'notEmptyInvalid' => 'Please select How did you heard about us'))))));
     // Other Information
     $this->addElement('text', 'other', array('label' => '', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Other Information')))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Strip all tags to prevent XSS errors
     $this->setElementFilters(array('StripTags'));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'portfolio-insurance-quote/step3.phtml'))));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
Пример #3
0
 public function init()
 {
     $this->addElement('select', 'property_let_type', array('label' => 'Property Let Type', 'required' => false, 'multiOptions' => array('' => 'Please select', '1' => 'Let Only', '2' => 'Managed', '3' => 'Rent Collect'), 'attribs' => array('class' => 'form-control')));
     $this->addElement('select', 'property_bedrooms', array('label' => 'How many bedrooms does this property have?', 'required' => false, 'multiOptions' => array('' => 'Please select', '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => '7+'), 'attribs' => array('class' => 'form-control')));
     $this->addElement('select', 'property_type', array('label' => 'Property type', 'required' => false, 'multiOptions' => array('' => 'Please select', '1' => 'Detached', '2' => 'Semi Detached', '3' => 'Flat', '4' => 'Terraced', '5' => 'Bungalow'), 'attribs' => array('class' => 'form-control')));
     $this->addElement('select', 'property_birth', array('label' => 'When was the property built?', 'required' => false, 'multiOptions' => array('' => 'Please select', '1' => 'Pre 1850', '2' => '1850 - 1899', '3' => '1900 - 1919', '4' => '1920 - 1945', '5' => '1946 - 1979', '6' => '1980 - 1990', '7' => '1991 - 2000', '8' => '2001 - 2010', '9' => '2011+'), 'attribs' => array('class' => 'form-control')));
     // Add total rent element
     $this->addElement('text', 'total_rent', array('label' => 'Total rent per month', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the total rent per month'))), array('Digits', true, array('messages' => array('notDigits' => 'Please enter a valid rental amount')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'currency', 'class' => 'currency form-control')));
     //Tenancy term element
     $this->addElement('select', 'tenancy_term', array('label' => 'Tenancy Term (months)', 'required' => true, 'multiOptions' => array('6' => 6, '12' => 12, '18' => 18, '24' => 24), 'validators' => array(array('Digits', true, array('messages' => array('notDigits' => 'Please select the tenancy term'))), array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the tenancy term', 'notEmptyInvalid' => 'Please select a valid tenancy term')))), 'attribs' => array('class' => 'form-control')));
     //Number of tenants element
     $this->addElement('select', 'no_of_tenants', array('label' => 'Number of tenants', 'required' => true, 'multiOptions' => array('1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, '10' => 10), 'validators' => array(array('Digits', true, array('messages' => array('notDigits' => 'Please select the number of tenants'))), array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the number of tenants', 'notEmptyInvalid' => 'Please select a valid number of tenants')))), 'attribs' => array('class' => 'form-control')));
     //The tenancy start date element
     $this->addElement('text', 'tenancy_start_date', array('label' => 'Tenancy start date (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenancy start date.')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'date', 'class' => 'form-control')));
     $tenancyStartDate = $this->getElement('tenancy_start_date');
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')));
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 60 * 60 * 24 * 30);
     $validator->setMessages(array('msgMinimum' => 'Tenancy start date cannot be in the past', 'msgMaximum' => 'Tenancy start date cannot be more than 30 days in the future'));
     $tenancyStartDate->addValidator($validator, true);
     //Grab view and add the date picker JavaScript files into the page head
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $view->headLink()->appendStylesheet('/assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker.min.css', 'screen');
     $view->headScript()->appendFile('/assets/vendor/jquery-date/js/date.js', 'text/javascript')->appendFile('/assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js', 'text/javascript')->appendFile('/assets/landlords-referencing/js/referencingDatePicker.js', 'text/javascript');
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/property-misc.phtml'))));
     // Strip all tags to prevent XSS errors
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
Пример #4
0
 /**
  * Create property subform
  *
  * @return void
  */
 public function init()
 {
     // Add managed element
     $this->addElement('select', 'property_managed', array('label' => 'Property let type', 'required' => true, 'multiOptions' => array('' => '--- Please select ---', 'Let Only' => 'Let Only', 'Managed' => 'Managed', 'Rent Collect' => 'Rent Collect'), 'separator' => '', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select a property let type', 'notEmptyInvalid' => 'Please select a valid property let type'))))));
     // Add LL permission element
     $this->addElement('radio', 'LL_Permission', array('label' => 'Where a Let Only agreement is in place you may give your Landlord permission to report and progress a claim on your behalf. Please tick this box to confirm if you have granted this permission, and that your Landlord has been made aware of, and has confirmed understanding of, the policy conditions around claiming.', 'required' => false, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to question: Where a Let Only agreement is in place you may give your Landlord permission to report and progress a claim on your behalf. Please tick this box to confirm if you have granted this permission, and that your Landlord has been made aware of, and has confirmed understanding of, the policy conditions around claiming.', 'notEmptyInvalid' => 'Please select answer to question: Where a Let Only agreement is in place you may give your Landlord permission to report and progress a claim on your behalf. Please tick this box to confirm if you have granted this permission, and that your Landlord has been made aware of, and has confirmed understanding of, the policy conditions around claiming.'))))));
     // Add house number + street address element
     $this->addElement('text', 'property_address1', array('label' => 'House Number + Street', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the house number + street address', 'notEmptyInvalid' => 'Please enter the house number + street address'))))));
     // Add address line 2 element
     $this->addElement('text', 'property_address2', array('label' => 'Address Line 2', 'required' => false, 'filters' => array('StringTrim')));
     // Add town/city address element
     $this->addElement('text', 'property_address3', array('label' => 'Town/City', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the town/city address', 'notEmptyInvalid' => 'Please enter the town/city address'))))));
     // Add county address element
     $this->addElement('text', 'property_address4', array('label' => 'County', 'required' => false, 'filters' => array('StringTrim')));
     // Add postcode element
     $this->addElement('text', 'property_postcode', array('label' => 'Postcode', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the postcode', 'notEmptyInvalid' => 'Please enter the postcode'))), array('Postcode'))));
     // Add the find address button
     $this->addElement('submit', 'property_address_lookup', array('ignore' => true, 'label' => 'Find address', 'class' => 'button'));
     $this->addElement('select', 'property_address', array('required' => false, 'label' => '', 'filters' => array('StringTrim'), 'class' => 'postcode_address', 'multiOptions' => array('' => 'Please select'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select property address', 'notEmptyInvalid' => 'Please select property address'))))));
     // Remove 'nnn not found in haystack' error
     $this->getElement('property_address')->setRegisterInArrayValidator(false);
     // Add rental element
     $this->addElement('text', 'property_rental', array('label' => 'Monthly Rental Amount', 'required' => true, 'attribs' => array('class' => 'currency'), 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the monthly rent', 'notEmptyInvalid' => 'Please enter the monthly rent'))), array('regex', true, array('pattern' => '/^\\d{1,}$/', 'messages' => 'Amount of monthly rent must contain at least one digit')), array('GreaterThan', true, array('min' => 0, 'messages' => 'Monthly rent must be above zero')))));
     // Add deposit element
     $this->addElement('text', 'property_deposit', array('label' => 'Deposit Amount', 'required' => true, 'attribs' => array('class' => 'currency'), 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the deposit amount', 'notEmptyInvalid' => 'Please enter the deposit amount'))), array('regex', true, array('pattern' => '/^\\d{1,}$/', 'messages' => 'Amount of deposit must contain at least one digit')), array('GreaterThan', true, array('min' => -1, 'messages' => 'Deposit amount must be zero or more')))));
     // Add rent in advance selection element
     $this->addElement('radio', 'rent_in_advance', array('label' => 'Has the first month’s rent been paid in advance', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to question: Has the first month’s rent been paid in advance?', 'notEmptyInvalid' => 'Please select answer to question: Has the first month’s rent been paid in advance?'))))));
     // Add tenancy start date element
     $this->addElement('text', 'tenancy_startdate', array('label' => 'Tenancy start date (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Tenancy start date can not be empty', 'notEmptyInvalid' => 'Please enter a valid tenancy start date'))))));
     $tenancy_startdate = $this->getElement('tenancy_startdate');
     $validator = new Zend_Validate_DateCompare();
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 60 * 60 * 24 * 365);
     // 365 days in future from todays date
     $validator->setMessages(array('msgMinimum' => 'Tenancy start date too far in the past', 'msgMaximum' => 'Tenancy start date too far in the future'));
     $tenancy_startdate->addValidator($validator, true);
     // Add policy start date element
     $this->addElement('text', 'policy_startdate', array('label' => 'Policy start date (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Policy start date can not be empty', 'notEmptyInvalid' => 'Please enter a valid Policy start date'))))));
     $tenant_startdate = $this->getElement('policy_startdate');
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 86400 * 14);
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 86400 * 365);
     $validator->setMessages(array('msgMinimum' => 'Policy start date cannot be more than 14 days in the past', 'msgMaximum' => 'Policy start date too far in the future'));
     $tenant_startdate->addValidator($validator, true);
     // Add policy end date element
     $this->addElement('text', 'policy_enddate', array('label' => 'Policy end date (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim'), 'attribs' => array('readonly' => true), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Policy end date can not be empty', 'notEmptyInvalid' => 'Please enter a valid Policy end date'))))));
     $policy_enddate = $this->getElement('policy_enddate');
     //        $validator = new Zend_Validate_DateCompare();
     //        $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 60 * 60 * 24);
     //        $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 60 * 60 * 24 * 365);
     //        $validator->setMessages(array(
     //            'msgMinimum' => 'Policy end date too far in the past',
     //            'msgMaximum' => 'Policy end date too far in the future'
     //        ));
     //        $policy_enddate->addValidator($validator, true);
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'rentguarantee/subforms/rent-recovery-plus-application-property.phtml'))));
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
Пример #5
0
 /**
  * Create policy details subform
  *
  * @return void
  */
 public function init()
 {
     // Add policy start date element
     $this->addElement('text', 'policy_start', array('label' => 'Policy start date', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select a policy start date'))))));
     $policy_start = $this->getElement('policy_start');
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')));
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 60 * 60 * 24 * 45);
     $validator->setMessages(array('msgMinimum' => 'Policy start date cannot be in the past', 'msgMaximum' => 'Policy start date cannot be more than 45 days in the future'));
     $policy_start->addValidator($validator, true);
     // Add policy end date element - used only for display purposes
     $this->addElement('text', 'policy_end', array('label' => 'Policy end date', 'required' => false, 'filters' => array('StringTrim')));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/policy-details.phtml'))));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
     // Grab view and add the date picker JavaScript files into the page head
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $view->headLink()->appendStylesheet('/assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker.min.css', 'screen');
     $view->headScript()->appendFile('/assets/vendor/jquery-date/js/date.js', 'text/javascript')->appendFile('/assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js', 'text/javascript')->appendFile('/assets/landlords-insurance-quote/js/policyStartDatePicker.js', 'text/javascript');
 }
 /**
  * Create personal details subform
  *
  * @return void
  */
 public function init()
 {
     // Add title element
     $this->addElement('select', 'title', array('label' => 'Title', 'required' => true, 'multiOptions' => self::$titles, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your title', 'notEmptyInvalid' => 'Please select your title'))))));
     // Add other title element
     $this->addElement('text', 'other_title', array('label' => 'Other title', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your title', 'notEmptyInvalid' => 'Please enter your title'))))));
     // Add first name element
     $this->addElement('text', 'first_name', array('label' => 'First name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your first name', 'notEmptyInvalid' => 'Please enter your first name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'First name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Add last name element
     $this->addElement('text', 'last_name', array('label' => 'Last name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your last name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Last name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Add phone number element
     $this->addElement('text', 'phone_number', array('label' => 'Contact phone number', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your phone number'))), array('regex', true, array('pattern' => '/^((\\+44\\s?\\(0\\)\\s?\\d{2,4})|(\\+44\\s?(01|02|03|07|08)\\d{2,3})|(\\+44\\s?(1|2|3|7|8)\\d{2,3})|(\\(\\+44\\)\\s?\\d{3,4})|(\\(\\d{5}\\))|((01|02|03|07|08)\\d{2,3})|(\\d{5}))(\\s|-|.)(((\\d{3,4})(\\s|-)(\\d{3,4}))|((\\d{6,7})))$/', 'messages' => 'Not a valid phone number'))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Add mobile number element
     $this->addElement('text', 'mobile_number', array('label' => 'Mobile number (if different)', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your mobile number'))), array('regex', true, array('pattern' => '/^07([\\d]{3})[(\\D\\s)]?[\\d]{3}[(\\D\\s)]?[\\d]{3}$/', 'messages' => 'Not a valid mobile phone number'))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Add e-mail element
     $this->addElement('text', 'email_address', array('label' => 'Email address', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your email address')))), 'attribs' => array('data-ctfilter' => 'yes')));
     $emailValidator = new Zend_Validate_EmailAddress();
     $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address"));
     $this->getElement('email_address')->addValidator($emailValidator);
     // Add DOB element
     $this->addElement('text', 'date_of_birth_at', array('label' => 'Date of birth (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your date of birth')))), 'attribs' => array('data-ctfilter' => 'yes')));
     $dob = $this->getElement('date_of_birth_at');
     $validator = new Zend_Validate_DateCompare();
     // todo: Parameterise valid date range
     $minYear = max(1902, date('Y') - 150);
     // On 32-bit systems (dev, staging) mktime cannot handle years below 1902
     $maxYear = date('Y') - 18;
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), $minYear));
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), $maxYear));
     $validator->setMessages(array('msgMinimum' => 'Date of birth cannot be more than ' . (date('Y') - $minYear) . ' years in the past', 'msgMaximum' => 'Date of birth cannot be less than 18 years in the past'));
     $dob->addValidator($validator, true);
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/personal-details.phtml'))));
     // Strip all tags to prevent XSS errors
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
     // Grab view and add the date picker JavaScript files into the page head
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $view->headLink()->appendStylesheet('/assets/cms/css/bootstrap-datepicker.css', 'screen');
     $view->headScript()->appendFile('/assets/vendor/js/date.js', 'text/javascript')->appendFile('/assets/cms/js/bootstrap-datepicker.js', 'text/javascript')->appendFile('/assets/cms/js/policyDobDatePicker.js', 'text/javascript');
 }
Пример #7
0
 /**
  * Create property subform
  *
  * @return void
  */
 public function init()
 {
     // Add managed element
     $this->addElement('select', 'property_managed', array('label' => 'Property let type', 'required' => true, 'multiOptions' => array('' => '--- Please select ---', '1' => 'Let Only', '2' => 'Managed', '3' => 'Rent Collect'), 'separator' => '', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select a property let type', 'notEmptyInvalid' => 'Please select a valid property let type'))))));
     // Add managed element
     $this->addElement('select', 'how_rg_offered', array('label' => 'How is Rent Guarantee offered to your landlord', 'required' => true, 'multiOptions' => array('' => '--- Please select ---', '1' => 'Free of charge', '2' => 'Included in Management Fees', '3' => 'Separate charge for Rent Guarantee to the landlord'), 'separator' => '', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select how Rent Guarantee is offered', 'notEmptyInvalid' => 'Please select a valid how Rent Guarantee is offered'))))));
     // Add house number + street address element
     $this->addElement('text', 'property_address1', array('label' => 'House Number + Street', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the house number + street address', 'notEmptyInvalid' => 'Please enter the house number + street address'))))));
     // Add town/city address element
     $this->addElement('text', 'property_address2', array('label' => 'Town/City', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the town/city address', 'notEmptyInvalid' => 'Please enter the town/city address'))))));
     // Add postcode element
     $this->addElement('text', 'property_postcode', array('label' => 'Postcode', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the postcode', 'notEmptyInvalid' => 'Please enter the postcode'))), array('Postcode'))));
     // Add the find address button
     $this->addElement('submit', 'property_address_lookup', array('ignore' => true, 'label' => 'Find address', 'class' => 'button'));
     $this->addElement('select', 'property_address', array('required' => false, 'label' => '', 'filters' => array('StringTrim'), 'class' => 'postcode_address', 'multiOptions' => array('' => 'Please select'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select property address', 'notEmptyInvalid' => 'Please select property address'))))));
     // Remove 'nnn not found in haystack' error
     $this->getElement('property_address')->setRegisterInArrayValidator(false);
     // Add rental element
     $this->addElement('text', 'property_rental', array('label' => 'Monthly Rental Amount', 'required' => true, 'attribs' => array('class' => 'currency'), 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the monthly rent', 'notEmptyInvalid' => 'Please enter the monthly rent'))), array('regex', true, array('pattern' => '/^\\d{1,}$/', 'messages' => 'Amount of monthly rent must contain at least one digit')), array('GreaterThan', true, array('min' => 0, 'messages' => 'Monthly rent must be above zero')))));
     // Add tenancy start date element
     $this->addElement('text', 'tenant_startdate', array('label' => 'Tenancy start date (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Tenancy start date can not be empty', 'notEmptyInvalid' => 'Please enter a valid Tenancy start date'))))));
     $tenant_startdate = $this->getElement('tenant_startdate');
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 60 * 60 * 24);
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 60 * 60 * 24 * 365);
     $validator->setMessages(array('msgMinimum' => 'Tenancy start date too far in the past', 'msgMaximum' => 'Tenancy start date too far in the future'));
     $tenant_startdate->addValidator($validator, true);
     // Add policy start date element
     $this->addElement('text', 'policy_startdate', array('label' => 'Policy start date (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Policy start date can not be empty', 'notEmptyInvalid' => 'Please enter a valid Policy start date'))))));
     $policy_startdate = $this->getElement('policy_startdate');
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 60 * 60 * 24);
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 60 * 60 * 24 * 365);
     $validator->setMessages(array('msgMinimum' => 'Policy start date too far in the past', 'msgMaximum' => 'Policy start date too far in the future'));
     $policy_startdate->addValidator($validator, true);
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'rentguarantee/subforms/absolute-application-property.phtml'))));
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
Пример #8
0
 /**
  * Initialise the form
  * 
  * @todo Validation
  * @return void 
  */
 public function init()
 {
     // Set request method
     $this->setMethod('POST');
     // Add first name element
     $this->addElement('text', 'quote_number', array('label' => 'Quote number', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your quote number', 'notEmptyInvalid' => 'Please enter your quote number'))), array('regex', true, array('pattern' => '/^[a-z]{4,}\\d+\\/?\\d+$/i', 'messages' => 'Quote number must use alphabetic and numeric characters and only basic punctuation (forward slash)'))), 'class' => 'form-control', 'attribs' => array('data-ctfilter' => 'yes')));
     // Email element
     $this->addElement('text', 'email', array('label' => 'Email address*', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your email address')))), 'class' => 'form-control', 'attribs' => array('data-ctfilter' => 'yes')));
     // Modify email error messages & add validator
     $emailValidator = new Zend_Validate_EmailAddress();
     $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address"));
     $this->getElement('email')->addValidator($emailValidator);
     // Add first name element
     $this->addElement('text', 'first_name', array('label' => 'First name*', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your first name', 'notEmptyInvalid' => 'Please enter your first name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'First name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))), 'class' => 'form-control', 'attribs' => array('data-ctfilter' => 'yes')));
     // Add last name element
     $this->addElement('text', 'last_name', array('label' => 'Last name*', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your last name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Last name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))), 'class' => 'form-control', 'attribs' => array('data-ctfilter' => 'yes')));
     // Add DOB element
     $this->addElement('text', 'date_of_birth_at', array('label' => 'Date of birth (dd/mm/yyyy)*', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your date of birth')))), 'class' => 'form-control', 'attribs' => array('data-ctfilter' => 'yes')));
     $dob = $this->getElement('date_of_birth_at');
     $validator = new Zend_Validate_DateCompare();
     // todo: Parameterise valid date range
     $minYear = max(1902, date('Y') - 150);
     // On 32-bit systems (dev, staging) mktime cannot handle years below 1902
     $maxYear = date('Y') - 18;
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), $minYear));
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), $maxYear));
     $validator->setMessages(array('msgMinimum' => 'Date of birth cannot be more than ' . (date('Y') - $minYear) . ' years in the past', 'msgMaximum' => 'Date of birth cannot be less than 18 years in the past'));
     $dob->addValidator($validator, true);
     // Add postcode element
     $this->addElement('text', 'cor_postcode', array('label' => 'Postcode (of your correspondence address)*', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a correspondence address postcode', 'notEmptyInvalid' => 'Please enter a correspondence address postcode'))), array('regex', true, array('pattern' => '/^[0-9a-z]{2,4}\\ ?[0-9a-z]{3}$/i', 'messages' => 'Postcode must be in postcode format'))), 'class' => 'form-control', 'attribs' => array('data-ctfilter' => 'yes')));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Retrieve', 'class' => 'btn btn-primary'));
     // Set up the element decorators
     $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'form-group'))));
     // Set up the decorator on the form and add in decorators which are removed
     $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'retrieve-quote-form'))->addDecorator('Form');
     // Remove the label from the submit button
     $element = $this->getElement('submit');
     $element->removeDecorator('label');
 }
 /**
  * Create personal details subform
  *
  * @return void
  */
 public function init()
 {
     // Add title element
     $this->addElement('select', 'title', array('label' => 'Title', 'required' => true, 'multiOptions' => array('Mr' => 'Mr', 'Mrs' => 'Mrs', 'Ms' => 'Ms', 'Miss' => 'Miss', 'Sir' => 'Sir', 'Mr and Mrs' => 'Mr and Mrs', 'Dr' => 'Dr', 'Professor' => 'Professor', 'Rev' => 'Rev', 'Other' => 'Other'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your title', 'notEmptyInvalid' => 'Please select your title'))))));
     // Add first name element
     $this->addElement('text', 'first_name', array('label' => 'First name', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your first name', 'notEmptyInvalid' => 'Please enter your first name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'First name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Add last name element
     $this->addElement('text', 'last_name', array('label' => 'Last name', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your last name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Last name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Add phone number element
     $this->addElement('text', 'phone_number', array('label' => 'Phone number', 'required' => true, 'validators' => array('TelephoneNumber', array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your phone number'))))));
     // Add mobile number element
     $this->addElement('text', 'mobile_number', array('label' => 'Mobile number', 'required' => true, 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your mobile number'))), array('regex', true, array('pattern' => '/^0\\d{10,}$/', 'messages' => 'Mobile number must begin with a zero and contain at least eleven digits'))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Add e-mail element
     $this->addElement('text', 'email_address', array('label' => 'Email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your email address')))), 'attribs' => array('data-ctfilter' => 'yes')));
     $emailValidator = new Zend_Validate_EmailAddress();
     $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address"));
     $this->getElement('email_address')->addValidator($emailValidator);
     // Add DOB element
     $this->addElement('text', 'date_of_birth_at', array('label' => 'Date of birth (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your date of birth')))), 'attribs' => array('data-ctfilter' => 'yes')));
     $dob = $this->getElement('date_of_birth_at');
     $validator = new Zend_Validate_DateCompare();
     // todo: Parameterise valid date range
     $minYear = max(1902, date('Y') - 150);
     // On 32-bit systems (dev, staging) mktime cannot handle years below 1902
     $maxYear = date('Y') - 18;
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), $minYear));
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), $maxYear));
     $validator->setMessages(array('msgMinimum' => 'Date of birth cannot be more than ' . (date('Y') - $minYear) . ' years in the past', 'msgMaximum' => 'Date of birth cannot be less than 18 years in the past'));
     $dob->addValidator($validator, true);
     // Strip all tags to prevent XSS errors and Trim all inputs
     $this->setElementFilters(array('StripTags', 'StringTrim'));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'portfolio-insurance-quote/subforms/personal-details.phtml'))));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
     // Grab view and add the date picker JavaScript files into the page head
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $view->headLink()->appendStylesheet('/assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker.min.css', 'screen');
     $view->headScript()->appendFile('/assets/vendor/jquery-date/js/date.js', 'text/javascript')->appendFile('/assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js', 'text/javascript')->appendFile('/assets/common/js/policyDobDatePicker.js', 'text/javascript');
 }
Пример #10
0
 /**
  * Create declaration and consent subform
  *
  * @return void
  */
 public function init()
 {
     $this->addElement('checkbox', 'consent_information_stored', array('required' => true, 'checkedValue' => '1', 'uncheckedValue' => null, 'decorators' => array('ViewHelper'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'We are unable to process your application if you do not agree to the referencing terms'))))));
     // Add company director/secretary name element
     $this->addElement('text', 'representive_name', array('label' => 'Company director/secretary name in full', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the company director/secretary\'s name', 'notEmptyInvalid' => 'Please enter the company director/secretary\'s name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Company director/secretary\'s name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)')))));
     // Add position element
     $this->addElement('text', 'representive_position', array('label' => 'Position', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the company director/secretary\'s position', 'notEmptyInvalid' => 'Please enter the company director/secretary\'s position'))))));
     // Add date element
     $this->addElement('text', 'application_date', array('label' => 'Date (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim'), 'readonly' => true));
     $application_date = $this->getElement('application_date');
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')));
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')));
     $validator->setMessages(array('msgMinimum' => 'Application date cannot be in the past', 'msgMaximum' => 'Application date cannot be in the future'));
     $application_date->addValidator($validator, true);
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'referencing/subforms/company-application-declaration.phtml'))));
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
     // Add submit button
     $this->addElement('submit', 'complete', array('label' => 'Complete'));
     $element = $this->getElement('complete');
     $element->removeDecorator('label');
 }
Пример #11
0
 /**
  * Create company details subform
  *
  * @return void
  */
 public function init()
 {
     // Add company name element
     $this->addElement('text', 'company_name', array('label' => 'Company name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the company name', 'notEmptyInvalid' => 'Please enter the company name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Company name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)')))));
     // Add company trading name element
     $this->addElement('text', 'company_tradingname', array('label' => 'Trading name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the company trading name', 'notEmptyInvalid' => 'Please enter the company trading name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Company trading name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)')))));
     // Add company registration number element
     $this->addElement('text', 'company_registration', array('label' => 'Registration number', 'required' => true, 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the company registration number', 'notEmptyInvalid' => 'Please enter the company registration number'))))));
     // Add company date of incorporation element
     $this->addElement('text', 'company_incorporation', array('label' => 'Date of incorporation (dd/mm/yyyy)', 'required' => true, 'filters' => array('StringTrim')));
     $company_incorporation = $this->getElement('company_incorporation');
     $validator = new Zend_Validate_DateCompare();
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 1);
     $validator->setMessages(array('msgMaximum' => 'Date of incorporation cannot be in the future'));
     $company_incorporation->addValidator($validator, true);
     // Add company contact name element
     $this->addElement('text', 'company_contactname', array('label' => 'Contact name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a company contact name', 'notEmptyInvalid' => 'Please enter a company contact name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Company contact name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)')))));
     // Add company telephone element
     $this->addElement('text', 'company_phone', array('label' => 'Telephone (inc STD)', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the company phone number'))), array('TelephoneNumber'))));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'referencing/subforms/company-application-companydetails.phtml'))));
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
Пример #12
0
 public function init()
 {
     $this->addSubForm(new LandlordsReferencing_Form_Subforms_DataProtection(), 'subform_dataprotection');
     $this->setMethod('post');
     //Prospective landlord name
     $this->addElement('select', 'title', array('label' => 'Title *', 'required' => true, 'multiOptions' => array('Mr' => 'Mr', 'Ms' => 'Ms', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Dr' => 'Dr', 'Prof' => 'Professor', 'Sir' => 'Sir'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your title', 'notEmptyInvalid' => 'Please select a valid title'))))));
     //First name entry
     $this->addElement('text', 'first_name', array('label' => 'First Name *', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your first name')))), 'attribs' => array('data-ctfilter' => 'yes')));
     //Last name entry
     $this->addElement('text', 'last_name', array('label' => 'Last Name *', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your last name')))), 'attribs' => array('data-ctfilter' => 'yes')));
     //Prospective landlord address details.
     $hiddenElement = new Zend_Form_Element_Hidden('property_number_name');
     $hiddenElement->setRequired(false);
     $hiddenElement->clearDecorators();
     $this->addElement($hiddenElement);
     // Add postcode element
     $this->addElement('text', 'property_postcode', array('label' => 'Postcode *', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a postcode', 'notEmptyInvalid' => 'Please enter a valid postcode'))), array('regex', true, array('pattern' => '/^[0-9a-z]{2,}\\ ?[0-9a-z]{2,}$/i', 'messages' => 'Postcode must be in postcode format'))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Add address select element
     $this->addElement('select', 'property_address', array('label' => 'Please select your address *', 'required' => true, 'multiOptions' => array('' => '--- please select ---'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your property address', 'notEmptyInvalid' => 'Please select your property address')))), 'attribs' => array('data-ctfilter' => 'yes')));
     //Phone number entry
     $this->addElement('text', 'phone_number', array('label' => 'Telephone Number *', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your phone number'))), array('regex', true, array('pattern' => '/^((\\+44\\s?\\(0\\)\\s?\\d{2,4})|(\\+44\\s?(01|02|03|07|08)\\d{2,3})|(\\+44\\s?(1|2|3|7|8)\\d{2,3})|(\\(\\+44\\)\\s?\\d{3,4})|(\\(\\d{5}\\))|((01|02|03|07|08)\\d{2,3})|(\\d{5}))(\\s|-|.)(((\\d{3,4})(\\s|-)(\\d{3,4}))|((\\d{6,7})))$/', 'messages' => 'Not a valid phone number'))), 'attribs' => array('data-ctfilter' => 'yes')));
     //Fax number entry
     $this->addElement('text', 'fax_number', array('label' => 'Fax Number', 'required' => false, 'validators' => array(array('regex', true, array('pattern' => '/^((\\+44\\s?\\(0\\)\\s?\\d{2,4})|(\\+44\\s?(01|02|03|07|08)\\d{2,3})|(\\+44\\s?(1|2|3|7|8)\\d{2,3})|(\\(\\+44\\)\\s?\\d{3,4})|(\\(\\d{5}\\))|((01|02|03|07|08)\\d{2,3})|(\\d{5}))(\\s|-|.)(((\\d{3,4})(\\s|-)(\\d{3,4}))|((\\d{6,7})))$/', 'messages' => 'Not a valid phone number'))), 'attribs' => array('data-ctfilter' => 'yes')));
     //Mobile number entry. We do not currently capture this, so WTF do we ask for it?
     $this->addElement('text', 'mobile_number', array('label' => 'Mobile Number *', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your mobile number'))), array('regex', true, array('pattern' => '/^07([\\d]{3})[(\\D\\s)]?[\\d]{3}[(\\D\\s)]?[\\d]{3}$/', 'messages' => 'Not a valid mobile phone number'))), 'attribs' => array('data-ctfilter' => 'yes')));
     //The email elements.
     $emailElement = new Zend_Form_Element_Text('email');
     $emailElement->setLabel('Email *');
     $emailElement->setRequired(true);
     $emailElement->addFilter(new Zend_Filter_StringTrim());
     $validator = new Zend_Validate_NotEmpty();
     $validator->setMessage('Please enter your email address');
     $emailElement->addValidator($validator);
     $validator = new Zend_Validate_EmailAddress();
     $validator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address"));
     $emailElement->addValidator($validator);
     $this->addElement($emailElement);
     //The password element.
     $passwordElement = new Zend_Form_Element_Password('password');
     $passwordElement->setRequired(true);
     $passwordElement->setLabel('Password *');
     $validator = new Zend_Validate_NotEmpty();
     $validator->setMessage('Please set a password');
     $passwordElement->addValidator($validator);
     $passwordElement->addValidator(new Zend_Validate_PasswordStrength());
     $validator = new Zend_Validate_Identical();
     $validator->setToken('confirm_password');
     $validator->setMessage('Passwords are not the same', Zend_Validate_Identical::NOT_SAME);
     $passwordElement->addValidator($validator);
     $this->addElement($passwordElement);
     //The confirm password element.
     $confirmPasswordElement = new Zend_Form_Element_Password('confirm_password');
     $confirmPasswordElement->setRequired(true);
     $confirmPasswordElement->setLabel('Confirm Password *');
     $validator = new Zend_Validate_NotEmpty();
     $validator->setMessage('Please confirm your password');
     $confirmPasswordElement->addValidator($validator);
     $this->addElement($confirmPasswordElement);
     // Security question & answer
     $this->addElement('select', 'security_question', array('label' => 'Security Question *', 'required' => true, 'multiOptions' => array('' => 'Please select'), 'registerInArrayValidator' => false, 'decorators' => array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your security question', 'notEmptyInvalid' => 'Please select your security question'))))));
     $this->addElement('text', 'security_answer', array('label' => 'Answer *', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your security answer'))))));
     $this->addElement('text', 'insurance_renewal_date', array('label' => 'Next Landlords Insurance Renewal Date (dd/mm/yyyy)', 'required' => false, 'filters' => array('StringTrim')));
     $insuranceRenewalDate = $this->getElement('insurance_renewal_date');
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')));
     //        $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 60 * 60 * 24 * 30);
     $validator->setMessages(array('msgMinimum' => 'Insurance renewal date cannot be in the past'));
     $insuranceRenewalDate->addValidator($validator, true);
     //Grab view and add the date picker JavaScript files into the page head
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $view->headLink()->appendStylesheet('/assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker.min.css', 'screen');
     $view->headScript()->appendFile('/assets/vendor/jquery-date/js/date.js', 'text/javascript')->appendFile('/assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js', 'text/javascript')->appendFile('/assets/landlords-referencing/js/referencingInsuranceRenewalDatePicker.js', 'text/javascript');
     //The submit button
     $submitElement = new Zend_Form_Element_Submit('submit');
     $submitElement->setIgnore(true);
     $this->addElement($submitElement);
     //Apply decorators. This has to be done unusually for t'ings to work.
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
     $submitElement->removeDecorator('label');
     $this->property_number_name->removeDecorator('HtmlTag');
     //Grab view and add the address lookup JavaScript into the page head
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $view->headScript()->appendFile('/assets/common/js/addressLookup.js', 'text/javascript');
 }
Пример #13
0
 /**
  * Overridden isValid() method for pre-validation code
  *
  * @param array $formData data typically from a POST or GET request
  *
  * @return bool
  */
 public function isValid($formData = array())
 {
     $validationResult = parent::isValid($formData);
     //$validationResult = true;
     // Constrain date input fields
     $tenancyStartDate = $this->getElement('tenancy_start_date');
     $tenancyRenewalDate = $this->getElement('tenancy_end_date');
     $originalCoverStartDate = $this->getElement('original_cover_start_date');
     $depositReceivedDate = $this->getElement('deposit_received_date');
     $firstArrearDate = $this->getElement('first_arrear_date');
     if ($formData['grounds_for_claim'] === 'rent-arrears') {
         $this->getElement('rent_arrears')->setRequired(true);
         $this->getElement('first_arrear_date')->setRequired(true);
     }
     // - Tenancy start date must be in the past
     $validator = new Zend_Validate_DateCompare();
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 1);
     $validator->setMessages(array('msgMaximum' => 'Tenancy start date must be in the past'));
     $tenancyStartDate->addValidator($validator, true);
     // - Original cover start date must be on or after tenancy start date
     // - Original cover start date must be in the past
     if (isset($formData['tenancy_start_date']) && $formData['tenancy_start_date'] != '') {
         $validator = new Zend_Validate_DateCompare();
         $validator->minimum = new Zend_Date($formData['tenancy_start_date']);
         $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 1);
         $validator->setMessages(array('msgMinimum' => 'Original cover start date must be after tenancy start date', 'msgMaximum' => 'Original cover start date must be in the past'));
         $originalCoverStartDate->addValidator($validator, true);
         // - Tenancy renewal date, if supplied, must be after tenancy start date
         $validator = new Zend_Validate_DateCompare();
         $validator->minimum = new Zend_Date($formData['tenancy_start_date']);
         $validator->setMessages(array('msgMinimum' => 'Tenancy renewal date must be after tenancy start date'));
         $tenancyRenewalDate->addValidator($validator, true);
         // - Date when deposit received must be in the past
         $validator = new Zend_Validate_DateCompare();
         $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 1);
         $validator->setMessages(array('msgMaximum' => 'Date when deposit received must be in the past'));
         $depositReceivedDate->addValidator($validator, true);
     }
     // - Date of first arrears must be in the past, and within the past 12 months
     $validatorChain = new Zend_Validate();
     $validator = new Zend_Validate_DateCompare();
     $validator->minimum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y') - 1));
     $validator->maximum = new Zend_Date(mktime(0, 0, 0, date('m'), date('d'), date('Y')) + 1);
     $validator->setMessages(array('msgMinimum' => 'Date of first arrears must be within the past 12 months', 'msgMaximum' => 'Date of first arrears must be in the past'));
     $validatorChain->addValidator($validator, true);
     if (isset($formData['tenancy_start_date']) && $formData['tenancy_start_date'] != '') {
         // - Date of first arrears must be after the tenancy start date
         $validator = new Zend_Validate_DateCompare();
         $validator->minimum = new Zend_Date($formData['tenancy_start_date']);
         $validator->setMessages(array('msgMinimum' => 'Date of first arrears must be after tenancy start date'));
         $validatorChain->addValidator($validator, true);
     }
     $firstArrearDate->addValidator($validatorChain, true);
     // If a postcode is or was present, look it up and populate the allowed values of the associated dropdown
     if (isset($formData['tenancy_postcode']) && trim($formData['tenancy_postcode']) != '') {
         Application_Core_FormUtils::getAddressByPostcode($this, $formData, trim($formData['tenancy_postcode']), 'tenancy_address', 'tenancy_housename', 'tenancy_street', 'tenancy_town', 'tenancy_city', 'rental property\'s');
     }
     if (isset($formData['tenant_vacated']) && intval(trim($formData['tenant_vacated'])) === 1) {
         $this->getElement('tenant_vacated_date')->setRequired(true);
         $this->getElement('arrears_at_vacant_possession')->setRequired(true);
         $this->getElement('tenantsforwarding_postcode')->setRequired(true);
     } else {
         if (isset($formData['tenant_vacated']) && intval(trim($formData['tenant_vacated'])) === 0) {
             if ($formData['tenant_occupation_confirmed_by_tel'] == 1) {
                 $this->getElement('tenant_occupation_confirmed_by_tel_dateofcontact')->setRequired(true);
                 $this->getElement('tenant_occupation_confirmed_by_tel_tenantname')->setRequired(true);
             }
             if ($formData['tenant_occupation_confirmed_by_email'] == 1) {
                 $this->getElement('tenant_occupation_confirmed_by_email_dateofcontact')->setRequired(true);
                 $this->getElement('tenant_occupation_confirmed_by_email_tenantname')->setRequired(true);
             }
             if ($formData['tenant_occupation_confirmed_by_visit'] == 1) {
                 $this->getElement('tenant_occupation_confirmed_by_visit_dateofvisit')->setRequired(true);
                 $this->getElement('tenant_occupation_confirmed_by_visit_individualattending')->setRequired(true);
                 $this->getElement('tenant_occupation_confirmed_by_visit_tenantname')->setRequired(true);
             }
         }
     }
     if (isset($formData['total_guarantors']) && trim($formData['total_guarantors']) != '') {
         $this->addGuarantors($formData);
     }
     if (isset($formData['total_tenants']) && trim($formData['total_tenants']) != '') {
         $this->addTenants($formData);
     }
     if (isset($formData['recent_complaints']) && trim($formData['recent_complaints']) == 1) {
         $this->getElement('recent_complaints_further_details')->setRequired(true);
     }
     if (isset($formData['grounds_for_claim']) && trim($formData['grounds_for_claim']) == 'other') {
         $this->getElement('grounds_for_claim_further_details')->setRequired(true);
     }
     if (isset($formData['section21_served']) && trim($formData['section21_served']) == 1) {
         $this->getElement('section21_expiry')->setRequired(true);
         $this->getElement('section21_moneydepositreceived')->setRequired(true);
         $this->getElement('section21_tds_complied_with')->setRequired(true);
         $this->getElement('section21_money_held_under_tds_deposit_scheme')->setRequired(true);
         $this->getElement('section21_tds_prescribed_information_to_tenant')->setRequired(true);
         $this->getElement('section21_landlord_deposit_in_property_form')->setRequired(true);
         $this->getElement('section21_returned_at_notice_serve_date')->setRequired(true);
     }
     if (isset($formData['section8_served']) && trim($formData['section8_served']) == 1) {
         $this->getElement('section8_expiry')->setRequired(true);
     }
     $parentValidationResult = parent::isValid($formData);
     if (isset($formData['tenant_vacated']) && trim($formData['tenant_vacated']) != '' && trim($formData['tenant_vacated']) == 0) {
         // Require at least one method of confirmation of tenants continued occupation of the
         // property to be completed.
         if ($formData['tenant_occupation_confirmed_by_tel'] != 1 && $formData['tenant_occupation_confirmed_by_email'] != 1 && $formData['tenant_occupation_confirmed_by_visit'] != 1) {
             // one of these confirmation check boxes
             $this->addError('At least one confirmation method of the tenants continued occupation ' . 'of the property must be provided');
             $validationResult = false;
         }
     }
     // Call original isValid()
     return $validationResult & $parentValidationResult;
 }