Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Initialize form (extended from HouseSimple_Form)
- *
- * @return void
- */
- public function init()
- {
- $this->setMethod('post');
- $this->setAttrib('class', 'Form Form--user');
- $this->setAction($this->getView()->url());
- // Contact details.
- $this->addElement('Select', 'title', array(
- 'label' => 'Title',
- 'required' => true,
- 'multiOptions' => array(
- '' => '',
- 'mr' => 'Mr',
- 'mrs' => 'Mrs',
- 'miss' => 'Miss',
- 'ms' => 'Ms',
- 'dr' => 'Dr',
- ),
- 'gridCellClasses' => array('u-size1of6', 'u-sm-size1of3')
- ));
- $this->addElement('Text', 'firstName', array(
- 'label' => 'First Name',
- 'required' => true,
- 'errorMessage' => 'Please enter your first name',
- 'filters' => array('StripTags', 'StringTrim'),
- 'gridCellClasses' => array('u-size1of3', 'u-sm-size2of3')
- ));
- $this->addElement('Text', 'surname', array(
- 'label' => 'Surname',
- 'required' => true,
- 'errorMessage' => 'Please enter your surname',
- 'filters' => array('StripTags', 'StringTrim'),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
- ));
- $this->addElement('Text', 'telephone', array(
- 'label' => 'Telephone',
- 'required' => true,
- 'errorMessage' => 'Please enter a valid phone number',
- 'filters' => array('StripTags', 'StringTrim'),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
- ));
- $this->addElement('Text', 'mobile', array(
- 'label' => 'Mobile Telephone',
- 'required' => true,
- 'errorMessage' => 'Please enter a valid phone number',
- 'filters' => array('StripTags', 'StringTrim'),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
- ));
- $this->addDisplayGroup(
- array(
- 'title',
- 'firstName',
- 'surname',
- 'telephone',
- 'mobile'
- ),
- 'contactDetails',
- array('legend' => 'Your details')
- );
- // Email fields.
- $this->addElement('Text', 'email', array(
- 'label' => 'Email',
- 'required' => true,
- 'errorMessage' => 'Please enter a valid email address',
- 'filters' => array('StripTags', 'StringTrim'),
- 'validators' => array(
- array(new Caboodle_Validate_UniqueEmail(array(
- 'message' => "'%value%' is already registered"
- )), true),
- array(new Zend_Validate_EmailAddress(array(
- 'messages' => array(
- Zend_Validate_EmailAddress::INVALID => 'Invalid email address',
- Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid email address',
- Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Invalid email address',
- Zend_Validate_EmailAddress::INVALID_LOCAL_PART => 'Invalid email address',
- Zend_Validate_EmailAddress::INVALID_MX_RECORD => 'Invalid email address',
- Zend_Validate_EmailAddress::INVALID_SEGMENT => 'Invalid email address'
- )
- )), true)
- ),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
- ));
- $this->addElement('Text', 'confirmEmail', array(
- 'label' => 'Confirm Email',
- 'required' => true,
- 'errorMessage' => 'my-details-error-message-email-confirm',
- 'filters' => array('StripTags', 'StringTrim'),
- 'validators' => array(array(new Caboodle_Validate_ConfirmEmailMatch(), true)),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
- ));
- $this->addDisplayGroup(
- array(
- 'email',
- 'confirmEmail'
- ),
- 'emailFields'
- );
- // Password fields.
- $this->addElement('password', 'password', array(
- 'label' => 'Choose Password',
- 'required' => true,
- 'errorMessage' => 'Password must be a minimum of 6 characters',
- 'filters' => array('StripTags', 'StringTrim'),
- 'validators' => array(array(new Zend_Validate_StringLength(array('min' => 6)), true)),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
- ));
- $this->addElement('password', 'confirmPassword', array(
- 'label' => 'Confirm Password',
- 'required' => true,
- 'errorMessage' => 'Password must match',
- 'filters' => array('StripTags', 'StringTrim'),
- 'validators' => array(array(new Caboodle_Validate_ConfirmPasswordMatch(), true)),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull')
- ));
- $this->addDisplayGroup(
- array(
- 'password',
- 'confirmPassword'
- ),
- 'passwordFields'
- );
- // Address fields.
- $this->addElement('Text', 'buildingNameNumber', array(
- 'label' => 'Building name or number',
- 'required' => true,
- 'errorMessage' => 'Please enter your building name or number',
- 'filters' => array('StripTags', 'StringTrim'),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
- 'attribs' => array('data-address-field' => 'buildingNameNumber')
- ));
- $this->addElement('Text', 'street', array(
- 'label' => 'Street',
- 'required' => true,
- 'errorMessage' => 'Please enter your street',
- 'filters' => array('StripTags', 'StringTrim'),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
- 'attribs' => array('data-address-field' => 'street')
- ));
- $this->addElement('Text', 'town', array(
- 'label' => 'Town',
- 'required' => true,
- 'errorMessage' => 'Please enter your town',
- 'filters' => array('StripTags', 'StringTrim'),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
- 'attribs' => array('data-address-field' => 'town')
- ));
- $geoData = new Services_Model_DbTable_PostCodeData();
- $result = $geoData->getAllCounties();
- $counties = array('' => '-- Choose -- ');
- foreach ($result as $value) {
- $counties[trim($value->county)] = trim($value->county);
- }
- $this->addElement('Select', 'county', array(
- 'label' => 'County',
- 'required' => true,
- 'errorMessage' => 'Please enter a valid county',
- 'multiOptions' => $counties,
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
- 'attribs' => array('data-address-field' => 'county')
- ));
- $this->addElement('Text', 'postcode', array(
- 'label' => 'Postcode',
- 'required' => true,
- 'errorMessage' => 'Please enter a valid postcode',
- 'validators' => array(array('PostCode', true)),
- 'filters' => array('StripTags', 'StringTrim'),
- 'gridCellClasses' => array('u-size1of2', 'u-sm-sizeFull'),
- 'attribs' => array('data-address-field' => 'postcode')
- ));
- $this->addDisplayGroup(
- array(
- 'buildingNameNumber',
- 'street',
- 'town',
- 'county',
- 'postcode'
- ),
- 'address',
- array('inline' => true, 'legend' => 'Your address')
- );
- // Signup interests.
- $this->addElement('MultiCheckbox', 'interests', array(
- 'multiOptions' => Hs_Model_User::getSignupInterests(),
- 'separator' => '',
- 'inline' => true
- ));
- $this->addDisplayGroup(
- array('interests'),
- 'userInterests',
- array('legend' => 'Your Interests')
- );
- // Buttons.
- $this->addElement('Button', 'save_btn', array(
- 'label' => 'Submit'
- ));
- $this->addDisplayGroup(
- array('save_btn'),
- 'buttons',
- array('order' => 500)
- );
- parent::init();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement