/**
  * Overrides init() in Zend_Form
  * 
  * @access public
  * @return void
  */
 public function init()
 {
     // init the parent
     parent::init();
     // set the form's method
     $this->setMethod('post');
     $groupModel = new Group();
     $groupsOptions = $groupModel->findPairs();
     $uniqueUsernameValidator = new Zend_Validate_Db_NoRecordExists(array('table' => 'backoffice_users', 'field' => 'username'));
     $uniqueEmailValidator = new Zend_Validate_Db_NoRecordExists(array('table' => 'backoffice_users', 'field' => 'email'));
     $groupsInArrayValidator = new Zend_Validate_InArray(array_keys($groupsOptions));
     $groupsInArrayValidator->setMessage('Please select at least one group. If you are not sure about which group is better, select "member".');
     $username = new Zend_Form_Element_Text('username');
     $username->setOptions(array('label' => 'Username', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $uniqueUsernameValidator)));
     $this->addElement($username);
     $email = new Zend_Form_Element_Text('email');
     $email->setOptions(array('label' => 'Email', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $uniqueEmailValidator)));
     $this->addElement($email);
     $firstname = new Zend_Form_Element_Text('firstname');
     $firstname->setOptions(array('label' => 'First name', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty')));
     $this->addElement($firstname);
     $lastname = new Zend_Form_Element_Text('lastname');
     $lastname->setOptions(array('label' => 'Last name', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty')));
     $this->addElement($lastname);
     $phoneNumber = new Zend_Form_Element_Text('phone_number');
     $phoneNumber->setOptions(array('label' => 'Phone number', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty')));
     $this->addElement($phoneNumber);
     $groups = new Zend_Form_Element_MultiCheckbox('groups');
     $groups->setOptions(array('label' => 'Select the one or more user groups for this user', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $groupsInArrayValidator), 'multiOptions' => $groupsOptions));
     $this->addElement($groups);
     $id = new Zend_Form_Element_Hidden('id');
     $id->setOptions(array('validators' => array(new Zend_Validate_Regex('/^\\d*$/'))));
     $this->addElement($id);
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setOptions(array('label' => 'Save user', 'required' => true, 'order' => 100));
     $this->addElement($submit);
     $this->addDisplayGroup(array('username', 'email', 'firstname', 'lastname', 'phone_number'), 'userdata')->getDisplayGroup('userdata')->setLegend('User details');
     $this->addDisplayGroup(array('groups'), 'usergroups')->getDisplayGroup('usergroups')->setLegend('Groups');
 }
示例#2
0
 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('action', DOMAIN . 'empconfiguration');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'empconfiguration');
     $empConfigureArray = array('emp_leaves' => 'Employee Leaves', 'emp_holidays' => 'Employee Holidays', 'emp_salary' => 'Salary Details', 'emppersonaldetails' => 'Personal Details', 'empcommunicationdetails' => 'Contact Details', 'emp_skills' => 'Employee Skills', 'emp_jobhistory' => 'Employee Job History', 'experience_details' => 'Experience Details', 'education_details' => 'Education  Details', 'trainingandcertification_details' => 'Training & Certification  Details', 'medical_claims' => 'Medical Claims', 'disabilitydetails' => 'Disability Details', 'dependency_details' => 'Dependency Details', 'visadetails' => 'Visa and Immigration Details', 'creditcarddetails' => 'Corporate Card Details', 'workeligibilitydetails' => 'Work Eligibility Details', 'emp_additional' => 'Additional Details', 'emp_renumeration' => 'Remuneration Details', 'emp_security' => 'Security Credentials', 'emp_performanceappraisal' => 'Performance Appraisal', 'emp_payslips' => 'Pay slips', 'emp_benifits' => 'Benefits');
     $checktype = new Zend_Form_Element_MultiCheckbox('checktype');
     foreach ($empConfigureArray as $key => $val) {
         $checktype->addMultiOption($key, $val);
     }
     $checktype->setRequired(true);
     $checktype->addValidator('NotEmpty', false, array('messages' => 'Please select atleast one employee configuration.'));
     $checktype->setOptions(array('class' => 'empconfigcheckbox'));
     $checktype->setSeparator(PHP_EOL);
     $checkall = new Zend_Form_Element_Checkbox('checkall');
     $checkall->setLabel('Check All');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($checktype, $checkall, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }