public function init() { $this->setMethod('post'); $this->setAttrib('id', 'formid'); $this->setAttrib('name', 'disabilitydetails'); $this->setAttrib('action', DOMAIN . 'disabilitydetails/add/'); $id = new Zend_Form_Element_Hidden('id'); $user_id = new Zend_Form_Element_Hidden('user_id'); // Description or Reason .... $desc = new Zend_Form_Element_Textarea('disability_description'); $desc->setAttrib('rows', 10); $desc->setAttrib('cols', 50); $desc->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\-\\,\\.\\&\\:\\"\'\\s]+$/i', 'messages' => array('regexNotMatch' => 'Please start with alphabets.'))))); //Disability Name ... $disability_name = new Zend_Form_Element_Text('disability_name'); $disability_name->addFilter(new Zend_Filter_StringTrim()); $disability_name->setAttrib("maxlength", 50); $disability_name->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\-\\s]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid disability name.'))))); //Disablity Type $disabilityType = new Zend_Form_Element_Select('disability_type'); $disabilityType->setRegisterInArrayValidator(false); $disabilityType->addMultiOptions(array('' => 'Select Disability type', 'blindness and visual impairments' => "Blindness and Visual Impairments", 'health impairments' => "Health Impairments", 'hearing impairments' => "Hearing Impairments", 'learning disabilities' => "Learning Disabilities", 'mental illness or emotional disturbances' => "Mental Illness or Emotional disturbances", 'mobility or orthopedic impairments' => "Mobility or Orthopedic Impairments", 'other impairments' => "Other Impairments", 'speech or language impairments' => "Speech or Language Impairments")); $disabilityType->setAttrib('onchange', 'showdisabilityField(this.id)'); //Other field for disability type.... $other_disability_type = new Zend_Form_Element_Text('other_disability_type'); $other_disability_type->addFilter(new Zend_Filter_StringTrim()); $other_disability_type->setAttrib("maxlength", 50); $disabilitytypeVal = Zend_Controller_Front::getInstance()->getRequest()->getParam('disability_type', null); if ($disabilitytypeVal == "other impairments") { //$other_disability_type->setRequired(true); //$other_disability_type->addValidator('NotEmpty', false, array('messages' => 'Please enter any other disability type.')); } $other_disability_type->addValidators(array(array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '/^[a-zA-Z][a-zA-Z0-9\\-\\s]+$/i', 'messages' => array('regexNotMatch' => 'Please enter valid disability type.'))))); //Form Submit.... $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->setLabel('Save'); $this->addElements(array($id, $user_id, $disability_name, $disabilityType, $other_disability_type, $desc, $submit)); $this->setElementDecorators(array('ViewHelper')); }
public function __construct(GD_Model_Project $project, $options = null, $new_project = false) { parent::__construct($options); $this->setName('projectSettings'); $project_name = new Zend_Form_Element_Text('name'); $project_name->setLabel(_r('Project Name'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $not_empty = new Zend_Validate_NotEmpty(); $not_empty->setMessage(_r('Please enter the project name')); $project_name->addValidators(array($not_empty)); // if we're adding a new project, we need to make sure it's unique if ($new_project) { $unique_name = new GD_Validate_UniqueName(); $project_name->addValidators(array($unique_name)); } $git_validator = new GD_Validate_GitUrl(); $repository_url = new Zend_Form_Element_Text('repositoryUrl'); $repository_url->setLabel(_r('Repository URL'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $not_empty = new Zend_Validate_NotEmpty(); $not_empty->setMessage(_r('Please enter the Repository URL')); $repository_url->addValidators(array($not_empty, $git_validator)); $deployment_branch = new Zend_Form_Element_Text('deploymentBranch'); $deployment_branch->setLabel(_r('Deployment Branch'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $not_empty = new Zend_Validate_NotEmpty(); $not_empty->setMessage(_r('Please enter the name of the Deployment Branch')); $deployment_branch->addValidators(array($not_empty)); if (!$new_project) { $deployment_branch->addValidator(new GD_Validate_GitBranch($project)); } $public_key = new Zend_Form_Element_Textarea('publicKey'); $public_key->setLabel(_r('Public Key'))->setRequired(false)->setAttrib('readonly', 'readonly'); $not_empty = new Zend_Validate_NotEmpty(); $not_empty->setMessage(_r('Please enter the Public Key')); $public_key->addValidators(array($not_empty)); $submit = new Zend_Form_Element_Image('btn_submit'); $submit->setImage('/images/buttons/small/save-changes.png'); $submit->class = "processing_btn size_small"; $this->addElements(array($project_name, $repository_url, $deployment_branch, $public_key, $submit)); }