public function init()
 {
     // contactnameElement
     $this->addElement('text', 'contactname', array('label' => 'Please give us a head office contact name', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please give us a head office contact name', 'notEmptyInvalid' => 'Invalid contact name'))))));
     // telephone_numberl Element
     $this->addElement('text', 'telephone_number', array('label' => 'Head office phone number', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Enter your Head Office telephone number', 'notEmptyInvalid' => 'Invalid UK telephone number for Head Office'))))));
     $phoneValidator = new Zend_Validate_TelephoneNumber();
     $phoneValidator->setMessages(array(Zend_Validate_TelephoneNumber::INVALID => "Invalid UK telephone number for Head Office"));
     $this->getElement('telephone_number')->addValidator($phoneValidator);
     // head_office_email_address Email Element
     $this->addElement('text', 'head_office_email_address', array('label' => 'Head office email address', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Enter your head office email address', 'notEmptyInvalid' => 'Head office email address is invalid'))))));
     $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('head_office_email_address')->addValidator($emailValidator);
     // head_office_fax_number Element
     $this->addElement('text', 'head_office_fax_number', array('label' => 'Head office fax number', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Enter your Head Office fax number', 'notEmptyInvalid' => 'Head Office Fax number is not a valid UK telephone number'))))));
     $faxValidator = new Zend_Validate_TelephoneNumber();
     $faxValidator->setMessages(array(Zend_Validate_TelephoneNumber::INVALID => "Head Office Fax number is not a valid UK telephone number"));
     $this->getElement('head_office_fax_number')->addValidator($faxValidator);
     // Strip all tags to prevent XSS errors
     $this->setElementFilters(array('StripTags'));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/head-office.phtml'))));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
 public function init()
 {
     // Type of organisation Element
     $this->addElement('select', 'organisation_type', array('label' => 'What sort of organisation are you?', 'required' => true, 'multiOptions' => array('' => '--- Please select ---', LettingAgents_Object_CompanyTypes::LimitedCompany => 'Limited Company', LettingAgents_Object_CompanyTypes::Partnership => 'Partnership', LettingAgents_Object_CompanyTypes::SoleTrader => 'Sole Trader', LettingAgents_Object_CompanyTypes::LimitedLiabilityPartnership => 'Limited liability partnership'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'What sort of organisation are you?', 'notEmptyInvalid' => 'What sort of organisation are you?'))))));
     // date_firm_established Element
     $this->addElement('text', 'date_established', array('id' => 'theDate', 'label' => 'When were you established?', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'When were you established?', 'notEmptyInvalid' => 'You have entered an invalid date for when were you established?'))))));
     // Append Javascripts
     //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/datePicker.css', 'screen');
     $view->headScript()->appendFile('/assets/vendor/js/date.js', 'text/javascript')->appendFile('/assets/cms/js/jquery.datePicker.js', 'text/javascript')->appendFile('/assets/cms/js/letting-agents/DatePicker.js', 'text/javascript');
     // is_associated Element
     $this->addElement('select', 'is_associated', array('label' => 'Is your company associated with any other letting business?', 'required' => true, 'multiOptions' => array('' => '--- Please select ---', '1' => 'Yes', '0' => 'No'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Is your company associated with any other company?', 'notEmptyInvalid' => 'Is your company associated with any other company?'))))));
     // if_yes Element
     $this->addElement('text', 'associated_text', array('label' => 'If yes please state', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'If yes please state', 'notEmptyInvalid' => 'If yes please state'))))));
     // contact_name Element
     $this->addElement('text', 'contact_name', array('label' => 'Your contact name', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Enter a contact name', 'notEmptyInvalid' => 'Invalid entry for contact name'))))));
     // contact_name Element
     $this->addElement('text', 'contact_number', array('label' => 'Your phone number', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A uk phone number is required', 'notEmptyInvalid' => 'Enter a valid uk phone number'))))));
     $phoneValidator = new Zend_Validate_TelephoneNumber();
     $phoneValidator->setMessages(array(Zend_Validate_TelephoneNumber::INVALID => "Enter a valid uk phone number"));
     $this->getElement('contact_number')->addValidator($phoneValidator);
     // General Email Element
     $this->addElement('text', 'general_email', array('label' => 'Your general email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A general email address is required', 'notEmptyInvalid' => 'Enter a valid email address for the general email address'))))));
     $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('general_email')->addValidator($emailValidator);
     // Strip all tags to prevent XSS errors
     $this->setElementFilters(array('StripTags'));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/personal-details.phtml'))));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
Example #3
0
 /**
  * Create lost login (password retrieval) form.
  *
  * @return void
  */
 public function init()
 {
     // Invoke the agent user manager
     $agentUserManager = new Manager_Core_Agent_User();
     // Create array of possible security questions
     $securityQuestions = array('' => '--- please select ---');
     $securityQuestions += $agentUserManager->getUserSecurityAllQuestions();
     $this->setMethod('post');
     // Add agent scheme number element
     $this->addElement('text', 'agentschemeno', array('label' => 'Agent Scheme Number', 'required' => false, 'filters' => array('Digits'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your Agent Scheme Number', 'notEmptyInvalid' => 'Please enter your Letting Agent Scheme Number'))), array('regex', true, array('pattern' => '/^\\d{5,}$/', 'messages' => 'Agent Scheme Number must contain at least 5 digits')))));
     // Add username element
     $this->addElement('text', 'username', array('label' => 'Username', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your username', 'notEmptyInvalid' => 'Please enter your username'))), array('regex', true, array('pattern' => '/^[a-z0-9]{6,64}$/i', 'messages' => 'Username must contain between 6 and 64 alphanumeric characters')))));
     // Add password element
     $this->addElement('password', 'password', array('label' => 'Password', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your password', 'notEmptyInvalid' => 'Please enter your password'))), array('regex', true, array('pattern' => '/^.{6,}$/', 'messages' => 'Password must contain at least 6 characters')))));
     // Add real name element
     $this->addElement('text', 'realname', array('label' => 'First name + last name', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your first name + last name', 'notEmptyInvalid' => 'Please enter your first name + last name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)')))));
     // Add security question element
     $this->addElement('select', 'question', array('label' => 'Security question', 'required' => false, 'multiOptions' => $securityQuestions, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select a security question', 'notEmptyInvalid' => 'Please select a security question'))))));
     // Add security answer element
     $this->addElement('text', 'answer', array('label' => 'Security answer', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your security answer', 'notEmptyInvalid' => 'Please enter your security answer'))), array('regex', true, array('pattern' => '/^[\\w\\ \\.\\-\'\\,]{2,}$/i', 'messages' => 'Security answer must contain at least two characters and only basic punctuation (hyphen, apostrophe, comma, full stop and space)')))));
     // Add e-mail element
     $this->addElement('text', 'email', array('label' => 'E-mail address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your e-mail address'))))));
     $emailValidator = new Zend_Validate_EmailAddress();
     $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid e-mail address'));
     $this->getElement('email')->addValidator($emailValidator);
     $this->setElementFilters(array('StripTags'));
     // Set up the element decorators
     $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors', array('HtmlTag', array('tag' => 'div'))));
     // Add login button
     $this->addElement('submit', 'login', array('label' => 'Login'));
 }
Example #4
0
 /**
  * Create property 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', 'Doctor' => 'Dr', 'Professor' => 'Professor', 'Reverend' => 'Rev', 'Other' => 'Other'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your title', 'notEmptyInvalid' => 'Please select landlord 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 landlord 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)')))));
     // 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 landlord 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)')))));
     // 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 landlord email address'))))));
     $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 confirm e-mail element
     $this->addElement('text', 'confirm_email_address', array('label' => 'Confirm email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please confirm landlord email address'))))));
     // Add phone number element
     $this->addElement('text', 'phone_number', array('label' => 'Phone number', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter landlord phone number'))))));
     // Add Question-1 element
     $this->addElement('radio', 'question1', array('label' => 'Are you aware of any circumstances which may give rise to a claim?', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to question: Are you aware of any circumstances which may give rise to a claim?', 'notEmptyInvalid' => 'Please select answer to question: Are you aware of any circumstances which may give rise to a claim?'))))));
     // Additional claim information element - textarea box
     $this->addElement('textarea', 'claiminfo', array('label' => 'Additional information', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please provide additional claim information.', 'notEmptyInvalid' => 'Please enter additional claim information'))))));
     // Add Question-2 element
     $this->addElement('radio', 'question2', array('label' => 'Will only permitted occupiers be living in the property?', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to question: Will only permitted occupiers be living in the property?', 'notEmptyInvalid' => 'Please select answer to question: Will only permitted occupiers be living in the property?'))))));
     // Add Question-3 element
     $this->addElement('radio', 'question3', array('label' => 'Any tenancy disputes, including late payment of rent?', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to question: Any tenancy disputes, including late payment of rent?', 'notEmptyInvalid' => 'Please select answer to question: Any tenancy disputes, including late payment of rent?'))))));
     // Add agreement element
     $this->addElement('radio', 'agreement', array('label' => 'Type of tenancy agreement', 'required' => true, 'multiOptions' => array('AST' => 'AST', 'Company' => 'Company'), 'separator' => ' ', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select answer to Type of tenancy agreement', 'notEmptyInvalid' => 'Please select answer to Type of tenancy agreement'))))));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'rentguarantee/subforms/rent-recovery-plus-application-landlord.phtml'))));
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
Example #5
0
 public function init()
 {
     $this->setMethod('post');
     // Email entry
     $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')))), '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);
     // Password entry
     $this->addElement('password', 'password', array('required' => true, 'label' => 'Password', 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your password')))), 'attribs' => array('data-ctfilter' => 'yes')));
     // Set up the element decorators
     $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors', array('HtmlTag', array('tag' => 'div'))));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Login', 'class' => 'button noalt'));
     // Add a forgotten password button
     $this->addElement('submit', 'forgottenPassword', array('ignore' => true, 'label' => 'Resend Password', 'class' => 'button noalt'));
     // Remove the label from the submit button
     $element = $this->getElement('submit');
     $element->removeDecorator('label');
     $element = $this->getElement('forgottenPassword');
     $element->removeDecorator('label');
     // Set up the decorator on the form and add in decorators which are removed
     $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'form_section one-col'))->addDecorator('Form');
 }
 /**
  * Create user details form (single user).
  *
  * @return void
  */
 public function init()
 {
     // Invoke the agent user manager
     $agentUserManager = new Manager_Core_Agent_User();
     // Create array of possible security questions
     $securityQuestions = array('' => '--- please select ---');
     $securityQuestions += $agentUserManager->getUserSecurityAllQuestions();
     // Add real name element
     $this->addElement('text', 'realname', array('label' => 'Full name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your full name', 'notEmptyInvalid' => 'Please enter your full name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)')))));
     // Add username element
     $this->addElement('text', 'username', array('label' => 'Username', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your username', 'notEmptyInvalid' => 'Please enter your username'))), array('regex', true, array('pattern' => '/^[a-z0-9]{1,64}$/i', 'messages' => 'Username must contain between 1 and 64 alphanumeric characters')))));
     if ($this->_role == Model_Core_Agent_UserRole::MASTER) {
         $this->getElement('username')->setRequired(true);
     } else {
         $this->getElement('username')->setAttrib('disabled', 'disabled');
     }
     // Add password1 element
     $passwordElement1 = new Zend_Form_Element_Password('password1');
     $passwordElement1->setRequired(false);
     $passwordElement1->setLabel('New password:'******'password2');
     $validator->setMessage('Passwords are not the same', Zend_Validate_Identical::NOT_SAME);
     $passwordElement1->addValidator($validator);
     $passwordElement2 = new Zend_Form_Element_Password('password2');
     $passwordElement2->setRequired(false);
     $passwordElement2->setLabel('New password (again)');
     $this->addElement($passwordElement2);
     // Add e-mail element
     $this->addElement('text', 'email', array('label' => 'E-mail address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your e-mail address'))))));
     $emailValidator = new Zend_Validate_EmailAddress();
     $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid e-mail address'));
     $this->getElement('email')->addValidator($emailValidator);
     if ($this->_role == Model_Core_Agent_UserRole::MASTER) {
         $this->getElement('email')->setRequired(true);
     } else {
         $this->getElement('email')->setAttrib('disabled', 'disabled');
     }
     // Add e-mail element
     $this->addElement('text', 'emailcopyto', array('label' => 'Copy e-mail to', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a copy-to e-mail address'))))));
     $emailCopyToValidator = new Zend_Validate_EmailAddress();
     $emailCopyToValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in copy-to e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid copy-to e-mail address'));
     $this->getElement('emailcopyto')->addValidator($emailCopyToValidator);
     // Add security question element
     $this->addElement('select', 'question', array('label' => 'Security question', 'required' => false, 'multiOptions' => $securityQuestions));
     // Add security answer element
     $this->addElement('text', 'answer', array('label' => 'Security answer', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[\\w\\ \\.\\-\'\\,]{2,}$/i', 'messages' => 'Security answer must contain at least two characters and only basic punctuation (hyphen, apostrophe, comma, full stop and space)')))));
     // Add master user element
     $this->addElement('checkbox', 'master', array('label' => 'Master user', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0'));
     // Add agent reports element
     $this->addElement('checkbox', 'reports', array('label' => 'Agent reports', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0'));
     // Add status element
     $this->addElement('checkbox', 'status', array('label' => 'Active', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0'));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'settings/subforms/useraccount.phtml', 'role' => $this->_role))));
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
    /**
     * @group ZF-7490
     */
    public function testSettingHostnameMessagesThroughEmailValidator()
    {
        $translations = array(
            'hostnameIpAddressNotAllowed' => 'hostnameIpAddressNotAllowed translation',
            'hostnameUnknownTld' => 'hostnameUnknownTld translation',
            'hostnameDashCharacter' => 'hostnameDashCharacter translation',
            'hostnameInvalidHostnameSchema' => 'hostnameInvalidHostnameSchema translation',
            'hostnameUndecipherableTld' => 'hostnameUndecipherableTld translation',
            'hostnameInvalidHostname' => 'hostnameInvalidHostname translation',
            'hostnameInvalidLocalName' => 'hostnameInvalidLocalName translation',
            'hostnameLocalNameNotAllowed' => 'hostnameLocalNameNotAllowed translation',
        );

        $this->_validator->setMessages($translations);
        $this->_validator->isValid('_XX.!!3xx@0.239,512.777');
        $messages = $this->_validator->getMessages();
        $found = false;
        foreach ($messages as $code => $message) {
            if (array_key_exists($code, $translations)) {
                $this->assertEquals($translations[$code], $message);
                $found = true;
                break;
            }
        }

        $this->assertTrue($found);
    }
 /**
  * Create insurance customer search form.
  *
  * @return void
  */
 public function init()
 {
     $this->setMethod('get');
     // Add first name element
     $this->addElement('text', 'firstName', array('label' => 'Customer First Name', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z\\-\\ \']+$/i', 'messages' => 'Customer First Name must contain alphabetic characters and only basic punctuation (hyphen, space and single quote)')))));
     // Add last name element
     $this->addElement('text', 'lastName', array('label' => 'Customer Last Name', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z\\-\\ \']+$/i', 'messages' => 'Customer Last Name must contain alphabetic characters and only basic punctuation (hyphen, space and single quote)')))));
     // Add line 1 property address element
     $this->addElement('text', 'address1', array('label' => 'Street Address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z0-9\\-\\ \'\\,\\.]+$/i', 'messages' => 'Street Address must contain alphanumeric characters and only basic punctuation (hyphen, space, single quote, comma and full stop)')))));
     // Add line 2 property address element
     $this->addElement('text', 'address2', array('label' => 'Town/City', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z0-9\\-\\ \'\\,\\.]+$/i', 'messages' => 'Town/City must contain alphanumeric characters and only basic punctuation (hyphen, space, single quote, comma and full stop)')))));
     // Add postcode element
     $this->addElement('text', 'postcode', array('label' => 'Post Code', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[a-z0-9\\ ]+$/i', 'messages' => 'Post Code must only contain alphanumeric characters and spaces')))));
     // Add telephone element
     $this->addElement('text', 'telephone', array('label' => 'Telephone', 'required' => false, 'filters' => array('StringTrim'), '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')))));
     // Add e-mail element
     $this->addElement('text', 'email', array('label' => 'Email', 'required' => false, 'filters' => array('StringTrim')));
     $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);
     // Set up the element decorators
     $this->setElementDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div'))));
     // Add search button
     $this->addElement('submit', 'search', array('label' => 'Search'));
 }
 public function init()
 {
     //Reference subject title element
     $this->addElement('select', 'personal_title', array('label' => 'Tenant Title', 'required' => true, 'multiOptions' => array('' => 'Not Known', '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 the tenant title', 'notEmptyInvalid' => 'Please select a valid tenant title')))), 'attribs' => array('class' => 'form-control')));
     //First name entry
     $this->addElement('text', 'first_name', array('label' => 'Tenant First Name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant\'s first name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control')));
     //Last name entry
     $this->addElement('text', 'last_name', array('label' => 'Tenant Last Name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant\'s last name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control')));
     // Email entry
     $this->addElement('text', 'email', array('label' => 'Tenant Email Address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the tenant\'s email address')))), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control')));
     $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 share of rent element
     $this->addElement('text', 'share_of_rent', array('label' => 'Share of rent per month (£)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the share of rent per month')), 'Digits', true, array('messages' => array('notDigits' => 'Please enter the share of rent per month', 'digitsStringEmpty' => 'Please enter the Share of rent per month')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'currency', 'class' => 'currency form-control')));
     // List the products based on the user choice.
     $productManager = new Manager_Referencing_Product();
     $session = new Zend_Session_Namespace('referencing_global');
     $productList = array();
     if ($session->displayRentGuaranteeProducts) {
         $productVariable = Model_Referencing_ProductVariables::RENT_GUARANTEE;
         $products = $productManager->getByVariable($productVariable);
         foreach ($products as $product) {
             if (!preg_match("/international/i", $product->name)) {
                 $productList[$product->key] = strtoupper($product->name);
             }
         }
     } else {
         $productVariable = Model_Referencing_ProductVariables::NON_RENT_GUARANTEE;
         $products = $productManager->getByVariable($productVariable);
         $productSelection = new Model_Referencing_ProductSelection();
         $productSelection->referenceId = 0;
         $productSelection->duration = 0;
         foreach ($products as $product) {
             if (!preg_match("/international/i", $product->name)) {
                 $productSelection->product = $product;
                 $price = $productManager->getPrice($productSelection);
                 $productList[$product->key] = strtoupper($product->name) . " (" . $price . " + VAT)";
             }
         }
     }
     $this->addElement('radio', 'product_choice', array('required' => true, 'multiOptions' => $productList, 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your product choice', 'notEmptyInvalid' => 'Please select a valid product choice'))))));
     //Identify if we need to indicate duration.
     if ($session->displayRentGuaranteeProducts) {
         //Determine the allowable durations... Needs to be done in ajax
         //Display duration box.
         $this->addElement('select', 'product_duration', array('label' => 'Product Duration (months)', 'required' => true, 'multiOptions' => array(6 => '6', 12 => '12'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the product duration', 'notEmptyInvalid' => 'Please select a valid product duration')))), 'attribs' => array('class' => 'form-control')));
     }
     //Completion method element
     $this->addElement('select', 'completion_method', array('label' => 'Completion Method', 'required' => true, 'multiOptions' => array(Model_Referencing_ReferenceCompletionMethods::ONE_STEP => 'Complete Information Now', Model_Referencing_ReferenceCompletionMethods::TWO_STEP => 'Email to Tenant'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the completion method', 'notEmptyInvalid' => 'Please select a valid completion method')))), 'attribs' => array('class' => 'form-control')));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'landlords-referencing/product-selection.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))));
 }
Example #10
0
 /**
  * (non-PHPdoc)
  * @see library/Zend/Form/Zend_Form_Element#init()
  */
 public function init()
 {
     parent::init();
     /**
      * @todo Change this wired error messages to something more user friendly, or even use simple email regex matching validator
      */
     $validatorHostname = new Zend_Validate_Hostname();
     $validatorHostname->setMessages(array(Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED => "'%value%' appears to be an IP address, but IP addresses are not allowed", Zend_Validate_Hostname::UNKNOWN_TLD => "'%value%' appears to be a DNS hostname but cannot match TLD against known list", Zend_Validate_Hostname::INVALID_DASH => "'%value%' appears to be a DNS hostname but contains a dash (-) in an invalid position", Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA => "'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'", Zend_Validate_Hostname::UNDECIPHERABLE_TLD => "'%value%' appears to be a DNS hostname but cannot extract TLD part", Zend_Validate_Hostname::INVALID_HOSTNAME => "'%value%' does not match the expected structure for a DNS hostname", Zend_Validate_Hostname::INVALID_LOCAL_NAME => "'%value%' does not appear to be a valid local network name", Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED => "'%value%' appears to be a local network name but local network names are not allowed"));
     $validatorEmail = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS, false, $validatorHostname);
     $validatorEmail->setMessages(array(Zend_Validate_EmailAddress::INVALID => "'%value%' is not a valid email address", Zend_Validate_EmailAddress::INVALID_HOSTNAME => "'%hostname%' is not a valid hostname for email address '%value%'", Zend_Validate_EmailAddress::INVALID_MX_RECORD => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'", Zend_Validate_EmailAddress::DOT_ATOM => "'%localPart%' not matched against dot-atom format", Zend_Validate_EmailAddress::QUOTED_STRING => "'%localPart%' not matched against quoted-string format", Zend_Validate_EmailAddress::INVALID_LOCAL_PART => "'%localPart%' is not a valid local part for email address '%value%'"));
     $this->addValidator($validatorEmail);
 }
Example #11
0
 public function init()
 {
     // Set request method
     $this->setMethod('post');
     // Email entry
     $this->addElement('span', 'email', array('label' => 'Email address', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'formvalue', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your email address'))))));
     // 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);
     //The password element.
     $passwordElement = new Zend_Form_Element_Password('password');
     $passwordElement->setRequired(true);
     $passwordElement->setLabel('Create your password');
     $passwordElement->setOptions(array('data-noAjaxValidate' => '1'));
     $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('Re-enter password');
     $confirmPasswordElement->setOptions(array('data-noAjaxValidate' => '1'));
     $validator = new Zend_Validate_NotEmpty();
     $validator->setMessage('Please confirm your password');
     $confirmPasswordElement->addValidator($validator);
     $this->addElement($confirmPasswordElement);
     // Security question & answer
     $securityQuestionModel = new Datasource_Core_SecurityQuestion();
     $securityQuestionOptions = array(0 => '- Please Select -');
     foreach ($securityQuestionModel->getOptions() as $option) {
         $securityQuestionOptions[$option['id']] = $option['question'];
     }
     $this->addElement('select', 'security_question', array('label' => 'Security Question', 'required' => false, 'multiOptions' => $securityQuestionOptions, 'decorators' => array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))));
     /* Value no longer mandatory, Redmine #11873
             $questionElement = $this->getElement('security_question');
             $validator = new Zend_Validate_GreaterThan(array('min'=> 0));
             $validator->setMessage('You must select a security question');
             $questionElement->addValidator($validator);
     */
     $this->addElement('text', 'security_answer', array('label' => 'Answer', 'required' => false, 'filters' => array('StringTrim')));
     // Set custom subform decorator - this is the default and gets overridden by view scripts in the tenants' and landlords' Q&Bs
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/register.phtml'))));
     // Set element decorators
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
     // Grab view and add the client-side password validation JavaScript into the page head
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $view->headScript()->appendFile('/assets/common/js/passwordValidation.js', 'text/javascript');
 }
Example #12
0
 /**
  * Initialise the form
  * 
  * @todo Validation
  * @return void 
  */
 public function init()
 {
     // Set request method
     $this->setMethod('POST');
     // Add title element
     $this->addElement('select', 'title', array('label' => 'Title', 'required' => true, 'multiOptions' => TenantsInsuranceQuote_Form_Subforms_PersonalDetails::$titles, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your title', 'notEmptyInvalid' => 'Please select your title')))), 'class' => 'form-control'));
     // 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'));
     // 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'));
     // Email element
     $this->addElement('text', 'email', array('label' => 'Email Address', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Email address is required')))), 'class' => 'form-control'));
     // 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);
     //The password element.
     $passwordElement = new Zend_Form_Element_Password('password', array('validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Password is required')))), 'class' => 'form-control'));
     $passwordElement->setRequired(true);
     $passwordElement->setLabel('Password');
     $passwordElement->setAttribs(array('class' => 'form-control'));
     $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');
     $confirmPasswordElement->setAttribs(array('class' => 'form-control'));
     $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'), 'decorators' => array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Security question is required')))), 'class' => 'form-control'));
     $this->addElement('text', 'security_answer', array('label' => 'Answer', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Security answer is required')))), 'class' => 'form-control'));
     $this->addElement('hidden', 'refno', array('required' => false, 'class' => 'noalt'));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Register', 'class' => 'btn btn-primary pull-right'));
     // Set up the element decorators
     $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors'));
     // Set up the decorator on the form and add in decorators which are removed
     $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'form_section'))->addDecorator('Form');
     // Remove the label from the submit button
     $element = $this->getElement('submit');
     $element->removeDecorator('label');
     $this->getElement('refno')->removeDecorator('HtmlTag');
 }
 /**
  * Create reference resend e-mail to applicant form.
  *
  * @return void
  */
 public function init()
 {
     // Add e-mail element
     $this->addElement('text', 'email', array('label' => 'E-mail address', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter recipient\'s e-mail address'))))));
     $emailValidator = new Zend_Validate_EmailAddress();
     $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid e-mail address'));
     $this->getElement('email')->addValidator($emailValidator);
     // Add replace e-mail address element
     $this->addElement('checkbox', 'replace', array('label' => 'Replace e-mail address', 'checkedValue' => '1'));
     // Set up the element decorators
     $this->setElementDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div'))));
     // Add send button
     $this->addElement('submit', 'send', array('label' => 'Send'));
 }
 public function init()
 {
     //Reference subject title element
     $this->addElement('select', 'personal_title', array('label' => 'Title', 'required' => true, 'multiOptions' => array('' => 'Not Known', '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 the title', 'notEmptyInvalid' => 'Please select a valid title')))), 'attribs' => array('class' => 'form-control')));
     //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 a first name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control')));
     //Middle name entry
     $this->addElement('text', 'middle_name', array('label' => 'Middle name', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a middle name')))), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control')));
     //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 a last name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control')));
     //Other name entry
     $this->addElement('text', 'other_name', array('label' => 'Other name which known by', 'required' => false, 'filters' => array('StringTrim'), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control')));
     //Phone number entry
     $this->addElement('text', 'telephone_day', array('label' => 'Daytime telephone number', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a daytime 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', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'phone', 'class' => 'form-control')));
     //Evening phone number
     $this->addElement('text', 'mobile_number', array('label' => 'Mobile number', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a mobile 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', 'class' => 'form-control')));
     // Email entry
     $this->addElement('text', 'email', array('label' => 'Email address', 'required' => false, 'filters' => array('StringTrim'), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control')));
     $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);
     //Date of birth. Use the 'tenancy start date' dropdowns for now, then re-purpose later.
     $this->addElement('text', 'tenancy_start_date', array('label' => 'Date of birth', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a date of birth'))))));
     //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/referencingBirthDatePicker.js', 'text/javascript');
     // Add bank account number element
     $this->addElement('text', 'bank_account_number', array('label' => 'Bank account number', 'required' => false, 'attribs' => array('class' => 'form-control')));
     // Add bank sort code element
     $this->addElement('text', 'bank_sortcode_number', array('label' => 'Bank sort code', 'required' => false, 'attribs' => array('class' => 'form-control')));
     //Residential status element
     $this->addElement('select', 'residential_status', array('label' => 'Current residential status', 'required' => true, 'multiOptions' => array('' => 'Please Select', Model_Referencing_ResidenceStatus::OWNER => 'Home Owner', Model_Referencing_ResidenceStatus::TENANT => 'Tenant', Model_Referencing_ResidenceStatus::LIVING_WITH_RELATIVES => 'Living with Relatives'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the residential status', 'notEmptyInvalid' => 'Please select a valid residential status')))), 'attribs' => array('class' => 'form-control')));
     //Occupational status element
     $this->addElement('select', 'occupational_type', array('label' => 'Current occupation status', 'required' => true, 'multiOptions' => array('' => 'Please Select', Model_Referencing_OccupationTypes::EMPLOYMENT => 'Permanently Employed', Model_Referencing_OccupationTypes::CONTRACT => 'On Contract', Model_Referencing_OccupationTypes::SELFEMPLOYMENT => 'Self Employed', Model_Referencing_OccupationTypes::RETIREMENT => 'Pensioner', Model_Referencing_OccupationTypes::STUDENT => 'Student', Model_Referencing_OccupationTypes::UNEMPLOYMENT => 'Unemployed', Model_Referencing_OccupationTypes::INDEPENDENT => 'Of Independant Means'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the occupational status', 'notEmptyInvalid' => 'Please select a valid occupational status')))), 'attribs' => array('class' => 'form-control')));
     //Drop down displayed only when applicant is Unemployed or a Student.
     $this->addElement('select', 'is_future_employment_secured', array('label' => 'Will the applicant start a new employed position during the tenancy term?', 'required' => false, 'multiOptions' => array('' => 'Please Select', 'Yes' => 'Yes', 'No' => 'No'), 'attribs' => array('class' => 'form-control')));
     //Add total gross annual income
     $this->addElement('text', 'total_annual_income', array('label' => 'Total gross annual income (£)', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the total gross annual income'))), array('Digits', true, array('messages' => array('notDigits' => 'Total gross annual income can only contain digits', 'digitsStringEmpty' => 'Total gross annual income can only contain digits')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'currency', 'class' => 'currency form-control')));
     //Occupation will change element
     $this->addElement('select', 'occupation_will_change', array('label' => 'Is occupation about to change?', 'required' => true, 'multiOptions' => array('' => 'Please Select', 'Yes' => 'Yes', 'No' => 'No'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select if this occupation is about to change', 'notEmptyInvalid' => 'Please select if this occupation is about to change')))), 'attribs' => array('class' => 'form-control')));
     //Has adverse credit history
     $this->addElement('select', 'has_adverse_credit', array('label' => 'Does the applicant have CCJs or adverse credit history?', 'required' => true, 'multiOptions' => array('' => 'Please Select', 'Yes' => 'Yes', 'No' => 'No'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select if there is adverse credit history', 'notEmptyInvalid' => 'Please select if there is adverse credit history')))), 'attribs' => array('class' => 'form-control')));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'landlords-referencing/reference-subject.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))));
 }
 /**
  * Create e-mail addresses form.
  *
  * @return void
  */
 public function init()
 {
     $emailValidator = new Zend_Validate_EmailAddress();
     $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid e-mail address'));
     // Add an e-mail element for each e-mail category
     foreach (Model_Core_Agent_EmailMapCategory::iterableKeys() as $categoryConstName => $val) {
         $categoryFriendlyName = Model_Core_Agent_EmailMapCategory::toString($val);
         // Add e-mail element
         $this->addElement('text', "email{$categoryConstName}", array('label' => $categoryFriendlyName, 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter your {$categoryFriendlyName} e-mail address"))))));
         $this->getElement("email{$categoryConstName}")->addValidator($emailValidator);
     }
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'settings/subforms/emailaddresses.phtml'))));
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
Example #16
0
 public function init()
 {
     // Set request method
     $this->setMethod('post');
     // Email entry
     $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'))))));
     // 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);
     // Password entry
     $this->addElement('password', 'password', array('required' => true, 'label' => 'Password', 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your password'))))));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/login.phtml'))));
     // Set element decorators
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
 public function init()
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $this->addElement('checkbox', 'declaration', array('required' => true, 'checkedValue' => '1', 'uncheckedValue' => null, 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You have not ticked the box to confirm you are a landlord. You cannot proceed with this application unless you are a landlord and you tick this box.', 'notEmptyInvalid' => 'You must agree to the declaration'))))));
     //Prospective landlord name
     $this->addElement('select', 'personal_title', array('label' => 'Title', 'required' => true, 'multiOptions' => array('Not Known' => 'Not Known', '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')))), 'attribs' => array('class' => 'form-control')));
     //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', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control')));
     //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', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control')));
     //Prospective landlord address details.
     $this->addElement('hidden', 'property_number_name', array('required' => false));
     // Add postcode element
     $this->addElement('text', 'property_postcode', array('label' => '', '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', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'postcode', 'class' => 'form-control')));
     // 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', 'class' => 'form-control')));
     // 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');
     // Add in any js specific to landlords referencing
     $view->headScript()->appendFile('/assets/landlords-referencing/js/addressLookup.js', 'text/javascript');
     //Phone number entry
     $this->addElement('text', 'telephone_day', array('label' => 'Tel No (day):', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A daytime number is required', 'notEmptyInvalid' => 'A daytime number is required'))), 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', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'phone', 'class' => 'form-control')));
     //Fax number entry
     $this->addElement('text', 'fax_number', array('label' => 'Fax No', '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 fax number'))), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control')));
     //Evening phone number
     $this->addElement('text', 'telephone_evening', array('label' => 'Tel No (evening):', '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', 'class' => 'form-control')));
     //Email entry. If the user is a PLL then we need to ensure that they do not erase their
     //email address and create an empty email value in the dbase.
     if ($session->userType == Model_Referencing_ReferenceUserTypes::PRIVATE_LANDLORD) {
         $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')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'email', 'class' => 'form-control')));
     } else {
         $this->addElement('text', 'email', array('label' => 'Email address', 'required' => false, 'filters' => array('StringTrim'), 'attribs' => array('data-ctfilter' => 'yes', 'data-validate' => 'validate', 'data-type' => 'email', 'class' => 'form-control')));
     }
     $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);
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'landlords-referencing/prospective-landlord.phtml'))));
     // Strip all tags to prevent XSS errors
     $this->setElementFilters(array('StripTags'));
     $this->setElementDecorators(array('ViewHelper', 'Label'));
     //Finally, remove the default decorators from the hidden elements.
     $this->property_number_name->removeDecorator('HtmlTag');
 }
 public function init()
 {
     // General Email Element
     $this->addElement('text', 'general_email_address', array('label' => 'Your general email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A general email address is required', 'notEmptyInvalid' => 'Enter a valid email address for the general email address'))))));
     // Add a new validator
     $generalEmailValidator = new Zend_Validate_EmailAddress();
     $generalEmailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Enter a valid email address for the general email address"));
     $this->getElement('general_email_address')->addValidator($generalEmailValidator);
     // Referencing Email Element
     $this->addElement('text', 'email_for_referencing', array('label' => 'Your referencing email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A referencing email address is required', 'notEmptyInvalid' => 'Enter a valid email address for the referencing email address'))))));
     //Add a new validator
     $referencingEmailValidator = new Zend_Validate_EmailAddress();
     $referencingEmailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Enter a valid email address for the referencing email address"));
     $this->getElement('email_for_referencing')->addValidator($referencingEmailValidator);
     // Insurance Email Element
     $this->addElement('text', 'email_for_insurance', array('label' => 'Your insurance email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'An insurance email address is required', 'notEmptyInvalid' => 'Enter a valid email address for the insurance email address'))))));
     // Add a new validator
     $insuranceEmailValidator = new Zend_Validate_EmailAddress();
     $insuranceEmailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Enter a valid email address for the insurance email address"));
     $this->getElement('email_for_insurance')->addValidator($insuranceEmailValidator);
     // RG Renwals Email Element
     $this->addElement('text', 'email_for_rg_renewals', array('label' => 'Your rent guarantee email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A rent guarantee address is required', 'notEmptyInvalid' => 'Enter a valid email address for the rent guarantee email address'))))));
     // Add a new validator
     $rgEmailValidator = new Zend_Validate_EmailAddress();
     $rgEmailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Enter a valid email address for the rent guarantee email address"));
     $this->getElement('email_for_rg_renewals')->addValidator($rgEmailValidator);
     // Invoicing Email Element
     $this->addElement('text', 'email_for_invoicing', array('label' => 'Your invoicing email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A invoicing email address is required', 'notEmptyInvalid' => 'Enter a valid email address for the invoicing email address'))))));
     // Add a new validator
     $invoicingEmailValidator = new Zend_Validate_EmailAddress();
     $invoicingEmailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Enter a valid email address for the invoicing email address"));
     $this->getElement('email_for_invoicing')->addValidator($invoicingEmailValidator);
     // Marketing Email Element
     $this->addElement('text', 'email_for_marketing', array('label' => 'Your HomeLet updates email address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'A HomeLet update email address is required', 'notEmptyInvalid' => 'Enter a valid email address for the HomeLet updates email address'))))));
     // Add a new validator
     $updatesEmailValidator = new Zend_Validate_EmailAddress();
     $updatesEmailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Enter a valid email address for the HomeLet updates email address"));
     $this->getElement('email_for_marketing')->addValidator($updatesEmailValidator);
     // Strip all tags to prevent XSS errors
     $this->setElementFilters(array('StripTags'));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/multiple-emails.phtml'))));
     $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))));
 }
 /**
  * Initialise the form
  *
  * @return void
  */
 public function init()
 {
     $this->setMethod('post');
     $this->addElement('text', 'landlords_name', array('required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please provide the landlords full name'))))));
     $this->addElement('text', 'landlords_email', array('required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please provide the landlords email address'))))));
     $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('landlords_email')->addValidator($emailValidator);
     $this->addElement('text', 'agent_job_title', array('required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please provide your job title'))))));
     $this->addElement('text', 'agent_contact_number', array('required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please provide your contact telephone number'))))));
     $this->addElement('text', 'policy_premium', array('required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please provide the policy premium'))))));
     $this->addElement('text', 'policy_term', array('required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please provide the policy term'))))));
     // Submit buttons
     $this->addElement('submit', 'formsubmit_refresh', array('name' => 'formsubmit_refresh', 'label' => 'Back'));
     $this->addElement('submit', 'formsubmit_back', array('name' => 'formsubmit_back', 'label' => 'Back'));
     $this->addElement('submit', 'formsubmit_email', array('name' => 'formsubmit_email', 'label' => 'Email'));
     $this->addElement('submit', 'formsubmit_post', array('name' => 'formsubmit_post', 'label' => 'Post'));
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'rentguarantee/subforms/rentguarantee-configure-renewal-document.phtml'))));
 }
Example #20
0
 public function init()
 {
     $this->setMethod('post');
     // Hidden referrer url
     $urlFilter = new Zend_Filter_PregReplace();
     // Filter to remove any host names
     $urlFilter->setMatchPattern('/[a-zA-Z0-9]*:\\/\\/.*\\//');
     $urlFilter->setReplacement('/');
     $this->addElement('hidden', 'referrerUrl', array('required' => false, 'filters' => array($urlFilter)));
     // Email entry
     $this->addElement('text', 'email', array('required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your email address'))))));
     // 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);
     // Password entry
     $this->addElement('password', 'password', array('required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your password'))))));
     // Set up the element decorators
     $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors'));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Retrieve My Quotes', 'class' => 'btn btn-primary pull-left'));
     // Add a resend validation link button
     $this->addElement('submit', 'resendValidation', array('ignore' => true, 'label' => 'Resend Account Validation', 'class' => 'btn btn-primary'));
     // Add a forgotten password button
     $this->addElement('submit', 'forgottenPassword', array('ignore' => true, 'label' => 'Reset Password', 'class' => 'btn btn-primary'));
     // Remove the label from the submit buttons
     $element = $this->getElement('submit');
     $element->removeDecorator('label');
     $element = $this->getElement('resendValidation');
     $element->removeDecorator('label');
     $element = $this->getElement('forgottenPassword');
     $element->removeDecorator('label');
     // Set up the decorator on the form and add in decorators which are removed
     /*$this->addDecorator('FormElements')
       ->addDecorator(
           'HtmlTag', 
           array('tag' => 'div', 'class' => 'form_section one-col')
           )
       ->addDecorator('Form');*/
     $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div')), 'Form'));
 }
 /**
  * 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');
 }
 /**
  * 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');
 }
Example #23
0
 public function init()
 {
     $this->name = new Zend_Form_Element_Text('name');
     $this->new_password = new Zend_Form_Element_Password('new_password');
     $this->confirm_password = new Zend_Form_Element_Password('confirm_password');
     $this->email = new Zend_Form_Element_Text('email');
     $this->biography = new Zend_Form_Element_Textarea('biography');
     $this->submit = new Zend_Form_Element_Submit('submit');
     $email_validator = new Zend_Validate_EmailAddress();
     $email_validator->setDeepMxCheck(false);
     $email_validator->setDomainCheck(false);
     $email_validator->setMessages(array(Zend_Validate_EmailAddress::INVALID_FORMAT => "Format Email Salah"));
     $confirm_password_validator = new Zend_Validate_Identical();
     $confirm_password_validator->setMessage("Kata sandi tidak cocok.");
     $this->biography->setAttribs(array('style' => 'width:100%;height:240px'));
     $this->name->setAttribs(array('class' => 'span6', 'placeholder' => 'Nama lengkap anda'));
     $this->email->addValidator($email_validator)->setAttribs(array('class' => 'span4', 'placeholder' => '*****@*****.**'));
     $this->submit->setAttribs(array('class' => 'btn btn-success'))->setLabel('Simpan');
     $this->confirm_password->addValidator($confirm_password_validator);
     $this->addElements(array($this->name, $this->new_password, $this->confirm_password, $this->email, $this->biography, $this->submit));
     $this->setElementDecorators(array('ViewHelper', 'Errors'));
 }
 /**
  * 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');
 }
 public function init()
 {
     //Prospective landlord name
     $this->addElement('select', 'personal_title', array('label' => 'Title', 'required' => true, 'multiOptions' => array('Not Known' => 'Not Known', '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 a title', 'notEmptyInvalid' => 'Please select a valid title')))), 'attribs' => array('class' => 'form-control')));
     //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 a first name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control')));
     //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 a last name')))), 'attribs' => array('data-ctfilter' => 'yes', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'name', 'class' => 'form-control')));
     //Prospective landlord address details.
     $this->addElement('hidden', 'property_number_name', array('required' => false));
     // Add postcode element
     $this->addElement('text', 'property_postcode', array('required' => true, 'label' => '', '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', 'data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'postcode', 'class' => 'form-control')));
     // 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 a property address', 'notEmptyInvalid' => 'Please select a property address')))), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control')));
     // 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');
     //Phone number entry
     $this->addElement('text', 'telephone_day', array('label' => 'Tel No (day):', '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', 'class' => 'form-control')));
     //Fax number entry
     $this->addElement('text', 'fax_number', array('label' => 'Fax No', '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 fax number'))), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control')));
     //Evening phone number
     $this->addElement('text', 'telephone_evening', array('label' => 'Tel No (evening):', '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', 'class' => 'form-control')));
     // Email entry
     $this->addElement('text', 'email', array('label' => 'Email address', 'required' => false, 'filters' => array('StringTrim'), 'attribs' => array('data-ctfilter' => 'yes', 'class' => 'form-control')));
     $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);
     // Set custom subform decorator
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'landlords-referencing/prospective-landlord.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))));
     //Finally, remove the default decorators from the hidden elements.
     $this->property_number_name->removeDecorator('HtmlTag');
 }
Example #26
0
 /**
  * Define the OC form elements
  *
  * @return void
  */
 public function init()
 {
     $this->setMethod('post');
     // Add agent name element
     $this->addElement('span', 'agent_name', array('label' => 'Name of letting agency', 'required' => false, 'readonly' => true, 'filters' => array('StringTrim'), 'class' => 'formvalue', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter letting agent name', 'notEmptyInvalid' => 'Please enter letting agent name'))))));
     // Add agent scheme number
     $this->addElement('span', 'agent_schemenumber', array('label' => 'Agent scheme number', 'required' => false, 'readonly' => true, 'filters' => array('StringTrim'), 'class' => 'formvalue', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter agent scheme number', 'notEmptyInvalid' => 'Please enter agent scheme number'))))));
     // Add agent contact name element
     $this->addElement('text', 'agent_contact_name', array('label' => 'Contact name', 'required' => true, 'filters' => array('StringTrim'), 'maxlength' => '100', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your contact name', 'notEmptyInvalid' => 'Please enter your contact name'))))));
     // Add the landlord find address button
     $this->addElement('submit', 'landlords_address_lookup', array('ignore' => true, 'label' => 'Find address', 'class' => 'button', 'onclick' => 'getPropertiesByPostcode($(\'#landlord_postcode\').val(), \'landlord_postcode\', \'landlord_address\',\'no_landlord_address_selector\'); return false;'));
     // Add agent postcode
     $this->addElement('text', 'agent_postcode', array('label' => 'Postcode', 'required' => true, 'filters' => array('StringTrim'), 'maxlength' => '10', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your office postcode', 'notEmptyInvalid' => 'Please enter your office postcode'))), array('regex', true, array('pattern' => '/^[0-9a-z]{2,}\\ ?[0-9a-z]{2,}$/i', 'messages' => 'Postcode must be in postcode format')))));
     Application_Core_FormUtils::createManualAddressInput($this, 'agent_housename', 'agent_street', 'agent_town', 'agent_city', false, '', true);
     // Add agent phone number element
     $this->addElement('text', 'agent_telephone', array('label' => 'Telephone number', 'required' => true, 'class' => 'input-pos-float', 'validators' => array('TelephoneNumber', array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your telephone number'))))));
     // Add agent e-mail element
     $this->addElement('text', 'agent_email', array('label' => 'Email address', 'required' => true, 'filters' => array('StringTrim'), 'maxlength' => '100', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your email address'))))));
     $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('agent_email')->addValidator($emailValidator);
     // Add agents directly authorised by FCA
     $this->addElement('span', 'agent_dir_by_fca', array('label' => 'Directly Authorised by the Financial Conduct Authority', 'filters' => array('StringTrim'), 'class' => 'formvalue'));
     $this->addElement('span', 'agent_ar_by_barbon', array('label' => 'Appointed Representative for Barbon Insurance Group Ltd', 'filters' => array('StringTrim'), 'class' => 'formvalue'));
     // Landlord1
     $subHeaderHtml = '<span style="font-size:smaller;">Please provide title, first name and surname</span>';
     $this->addElement('text', 'landlord1_name', array('label' => "Full name<br>{$subHeaderHtml}", 'required' => true, 'filters' => array('StringTrim'), 'maxlength' => '80', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please landlords name'))))));
     // landlor company Name
     $this->addElement('text', 'landlord_company_name', array('label' => 'Company name', 'required' => false, 'filters' => array('StringTrim'), 'maxlength' => '100'));
     // Add Landlord postcode
     $subHeaderHtml = '<span style="font-size:smaller;">Landlords residential address (This cannot be a C/O address due to the requirements for Legal Proceedings)</span>';
     $this->addElement('text', 'landlord_postcode', array('label' => "Landlord Home Address Postcode<br>{$subHeaderHtml}", 'required' => true, 'filters' => array('StringTrim'), 'maxlength' => '10', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter Landlord\'s postcode', 'notEmptyInvalid' => 'Please enter Landlord\'s postcode'))), array('regex', true, array('pattern' => '/^[0-9a-z]{2,}\\ ?[0-9a-z]{2,}$/i', 'messages' => 'Postcode must be in postcode format')))));
     Application_Core_FormUtils::createManualAddressInput($this, 'landlord_housename', 'landlord_street', 'landlord_town', 'landlord_city', false);
     $this->addElement('select', 'landlord_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 landlord address', 'notEmptyInvalid' => 'Please select landlord address'))))));
     // Remove 'nnn not found in haystack' error
     $this->getElement('landlord_address')->setRegisterInArrayValidator(false);
     // Add hidden element for postcode
     $this->addElement('hidden', 'landlord_address_id', array('value' => 1, 'class' => 'noborder'));
     // Add agent phone number element
     $this->addElement('text', 'landlord_telephone', array('label' => 'Telephone number', 'required' => false, 'class' => 'input-pos-float', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter landlord phone number'))), array('regex', true, array('pattern' => $this->PHONE_RGX, 'messages' => 'Not a valid phone number')))));
     // Add Landlord e-mail element
     $this->addElement('text', 'landlord_email', array('label' => 'Email address', 'required' => false, 'filters' => array('StringTrim'), 'maxlength' => '100', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter landlord email address'))))));
     $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('landlord_email')->addValidator($emailValidator);
     // Set decorators
     $this->clearDecorators();
     $this->setDecorators(array('Form'));
     $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors'));
     // Add the next button
     $this->addElement('submit', 'next', array('ignore' => true, 'label' => 'Continue to Step 2', 'onclick' => 'window.location="step2"'));
     // Add the save and exit button
     $this->addElement('button', 'save', array('ignore' => true, 'label' => 'Save & Exit'));
     // Landlord Address decorators
     $landlordAddressLookUp = $this->getElement('landlords_address_lookup');
     $landlordAddressLookUp->clearDecorators();
     $landlordAddressLookUp->setDecorators(array('ViewHelper'));
     // Nav decorators
     $next = $this->getElement('next');
     $next->clearDecorators();
     $next->setDecorators(array('ViewHelper'));
     $save_and_exit = $this->getElement('save');
     $save_and_exit->clearDecorators();
     $save_and_exit->setDecorators(array('ViewHelper'));
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'rentguaranteeclaims/subforms/you-and-landlords.phtml'))));
     //Allow HTML to be inserted into the labels.
     $this->getElement('landlord1_name')->getDecorator('Label')->setOption('escape', false);
     $this->getElement('landlord_postcode')->getDecorator('Label')->setOption('escape', false);
 }
 public function sendPdfAction()
 {
     // Check user is logged in to get ASN from
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('hl_connect'));
     if ($auth->hasIdentity()) {
         // Fetch ASN and agent user ID
         $asn = $auth->getStorage()->read()->agentschemeno;
         $userId = $auth->getStorage()->read()->agentid;
         $request = $this->getRequest();
         if (!is_null($request->getParam('filename'))) {
             $filename = $request->getParam('filename');
             // Is this a special agent application form that requires content injection and is sent to a specific agent user?
             if (preg_match('/agent-form\\?form=([\\w\\-]+)$/i', $filename, $matches) > 0) {
                 // Yes, requires agent content injection and sending
                 $formName = $matches[1];
                 $agentFormManager = new Manager_Connect_AgentForm();
                 $agentFormManager->populateAndOuput($formName, $asn, $userId, 'email');
                 echo "{\"successMessage\":\"Email sent\"}\n";
                 exit;
             } else {
                 // Standard PDF, load and send as-is
                 $filters = array('*' => array('StringTrim', 'HtmlEntities', 'StripTags'));
                 // Check e-mail present and valid
                 $formInput['to'] = htmlentities($request->getParam('to'));
                 $formInput['message'] = htmlentities($request->getParam('message'));
                 $formInput['filename'] = htmlentities($request->getParam('filename'));
                 $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'));
                 $validators = array('*' => array('allowEmpty' => true), 'email' => $emailValidator);
                 $validate = new Zend_Filter_Input($filters, $validators, $formInput);
                 if ($validate->isValid()) {
                     // Security - ensure PDF can only be requested from public webspace
                     $params = Zend_Registry::get('params');
                     $realpath = realpath($params->connect->basePublicPath . $validate->filename);
                     if (strpos($realpath, $params->connect->safePublicRealPathContains) !== false && strtolower(substr($realpath, -4, 4)) == '.pdf') {
                         // Generate e-mail
                         $mailer = new Application_Core_Mail();
                         $mailer->setTo($validate->to, $validate->to);
                         // TODO: Parameterise:
                         $mailer->setFrom('*****@*****.**', 'HomeLet');
                         $mailer->setSubject("{$validate->filename} sent by HomeLet");
                         $mailer->setBodyText($validate->message);
                         $mailer->addAttachment($realpath, $validate->filename);
                         $mailer->send();
                         echo "{\"successMessage\":\"Email sent\"}\n";
                         exit;
                     }
                 } else {
                     echo "{\"errorMessage\":\"Invalid e-mail address\"}\n";
                     exit;
                 }
             }
         } else {
             echo "{\"errorMessage\":\"No PDF specified\"}\n";
             exit;
         }
     }
     echo "{\"errorMessage\":\"There was an error, please try again later\"}\n";
 }
Example #28
0
 public function addNameElement($default = '')
 {
     require_once 'Zend/Validate/NotEmpty.php';
     $notEmpty = new Zend_Validate_NotEmpty();
     $notEmpty->setMessages(array(Zend_Validate_NotEmpty::IS_EMPTY => $this->getTranslator()->translate('accountFormHintNameNotEmpty')));
     require_once 'Zend/Filter/StringToLower.php';
     $filter = new Zend_Filter_StringToLower('utf-8');
     require_once 'Zend/Form/Element/Text.php';
     $element = new Zend_Form_Element_Text($this->getNameParam());
     $element->clearDecorators()->addDecorator('viewHelper')->addValidator($notEmpty)->setRequired(true)->addFilter($filter)->setValue($default);
     #if($this->getPermiso()->getRequest()->getPost($this->getNameParam()))
     #if((isset($_POST[$this->getNameParam()]))
     #{
     require_once 'Zend/Validate/EmailAddress.php';
     $emailAddress = new Zend_Validate_EmailAddress();
     $emailAddressMessage = $this->getTranslator()->translate('accountFormHintNameEmailAddressInvalid');
     $emailAddress->setMessages(array(Zend_Validate_EmailAddress::INVALID => $emailAddressMessage, Zend_Validate_EmailAddress::INVALID_HOSTNAME => $emailAddressMessage, Zend_Validate_EmailAddress::INVALID_MX_RECORD => $emailAddressMessage, Zend_Validate_EmailAddress::DOT_ATOM => $emailAddressMessage, Zend_Validate_EmailAddress::QUOTED_STRING => $emailAddressMessage, Zend_Validate_EmailAddress::INVALID_LOCAL_PART => $emailAddressMessage, Zend_Validate_EmailAddress::LENGTH_EXCEEDED => $emailAddressMessage));
     $element->addValidator($emailAddress);
     #}
     $this->addElement($element);
     return $this;
 }
 public function landlordLowdownSignupAction()
 {
     // Throw a 404 error
     throw new Zend_Controller_Action_Exception("This page doesn't exist", 404);
     die;
     // NOT CURRENTLY IN USE
     // @codeCoverageIgnoreStart
     $formInput = array();
     $formInput['email'] = htmlentities($this->getRequest()->getParam('email'));
     // Check e-mail present and valid
     $filters = array('email' => 'StringTrim');
     $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'));
     $validators = array('email' => $emailValidator);
     $validate = new Zend_Filter_Input($filters, $validators, $formInput);
     if ($validate->isValid()) {
         // E-mail address valid, instantiate subscription manager using the e-mail address
         $email = $formInput['email'];
         $subscriptionManager = new Manager_Core_Subscription($email);
         // Create subscription
         try {
             $subscriptionManager->subscribe('landlord-lowdown');
             $this->view->content = "Subscribed to Landlord Lowdown with address <em>{$email}</em>.  Please check your e-mail (including any bulk mail filters) to confirm activation of your subscription.";
         } catch (Exception $e) {
             $this->view->content = 'Sorry, we were unable to set up your subscription for the following reason(s):<br /><br />' . $e->getMessage();
         }
     } else {
         // E-mail address didn't validate, show flattened errors
         $allErrors = $validate->getMessages();
         $errors = '';
         foreach ($allErrors as $key => $val) {
             foreach ($val as $subkey => $subval) {
                 $errors .= "{$subval}<br />";
             }
         }
         $this->view->content = 'Sorry, we were unable to set up your subscription for the following reason(s):<br /><br />' . $errors;
     }
     // Disable the layout
     $this->_helper->layout->disableLayout();
     // @codeCoverageIgnoreEnd
 }
Example #30
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');
 }