当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Form_Element_Radio::addValidator方法代码示例

本文整理汇总了PHP中Zend_Form_Element_Radio::addValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Radio::addValidator方法的具体用法?PHP Zend_Form_Element_Radio::addValidator怎么用?PHP Zend_Form_Element_Radio::addValidator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Form_Element_Radio的用法示例。


在下文中一共展示了Zend_Form_Element_Radio::addValidator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     $this->setMethod('post');
     //$this->setAttrib('action',DOMAIN.'language/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'servicedeskrequests');
     $id = new Zend_Form_Element_Hidden('id');
     $postid = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
     $businessunit_id = new Zend_Form_Element_Select('businessunit_id');
     $businessunit_id->setLabel("Business Unit");
     $businessunit_id->setAttrib('class', 'selectoption');
     if ($postid == '') {
         $businessunit_id->setAttrib('onchange', 'displayemployees(this)');
         $bunitModel = new Default_Model_Businessunits();
         $bunitdata = $bunitModel->fetchAll('isactive=1', 'unitname');
         $businessunit_id->addMultiOptions(array('' => 'Select Business unit', '0' => 'No Business Unit'));
         foreach ($bunitdata->toArray() as $data) {
             $businessunit_id->addMultiOption($data['id'], $data['unitname']);
         }
     } else {
         $businessunit_id->addMultiOptions(array('' => 'Select Business unit'));
     }
     $businessunit_id->setRegisterInArrayValidator(false);
     $businessunit_id->setRequired(true);
     $businessunit_id->addValidator('NotEmpty', false, array('messages' => 'Please select business unit.'));
     $department_id = new Zend_Form_Element_Select('department_id');
     $department_id->setLabel("Department");
     $department_id->setAttrib('class', 'selectoption');
     $department_id->addMultiOption('', 'Select Department');
     if ($postid == '') {
         $department_id->setAttrib('onchange', 'displayemployees(this)');
     }
     $department_id->setRegisterInArrayValidator(false);
     $service_desk_flag = new Zend_Form_Element_Radio('service_desk_flag');
     $service_desk_flag->setLabel("Applicability");
     $service_desk_flag->setAttrib('onclick', 'changeimplementation(this)');
     $service_desk_flag->addMultiOptions(array('1' => 'Business unit wise', '0' => 'Department wise'));
     $service_desk_flag->setSeparator('');
     $service_desk_flag->setValue(1);
     $service_desk_flag->setRegisterInArrayValidator(false);
     $service_desk_flag->setRequired(true);
     $service_desk_flag->addValidator('NotEmpty', false, array('messages' => 'Please select applicability.'));
     $service_desk_id = new Zend_Form_Element_Select('service_desk_id');
     $service_desk_id->setLabel("Category");
     $service_desk_id->setAttrib('class', 'selectoption');
     $service_desk_id->addMultiOption('', 'Select category');
     $service_desk_id->setRegisterInArrayValidator(false);
     $service_desk_id->setRequired(true);
     $service_desk_id->addValidator('NotEmpty', false, array('messages' => 'Please select category.'));
     $request_recievers = new Zend_Form_Element_Multiselect('request_recievers');
     $request_recievers->setLabel("Executors");
     $request_recievers->setAttrib('class', 'selectoption');
     $request_recievers->setRegisterInArrayValidator(false);
     $request_recievers->setRequired(true);
     $request_recievers->addValidator('NotEmpty', false, array('messages' => 'Please select executor.'));
     $approvingauthority = new Zend_Form_Element_Select('approvingauthority');
     $approvingauthority->setLabel("No. of Approvers");
     $approvingauthority->setAttrib('class', 'selectoption');
     $approvingauthority->setAttrib('onchange', 'displayapprovingauthority(this)');
     $approvingauthority->addMultiOptions(array('' => 'Select no. of approvers', '1' => '1', '2' => '2', '3' => '3'));
     $approvingauthority->setRegisterInArrayValidator(false);
     $approvingauthority->setRequired(true);
     $approvingauthority->addValidator('NotEmpty', false, array('messages' => 'Please select no. of approvers.'));
     $approver_1 = new Zend_Form_Element_Select('approver_1');
     $approver_1->setLabel("Approver 1");
     $approver_1->setAttrib('class', 'selectoption');
     $approver_1->addMultiOption('', 'Select Approver 1');
     $approver_1->setAttrib('onchange', 'displayapprovingauthority(this)');
     $approver_1->setRegisterInArrayValidator(false);
     $approver_2 = new Zend_Form_Element_Select('approver_2');
     $approver_2->setLabel("Approver 2");
     $approver_2->setAttrib('class', 'selectoption');
     $approver_2->addMultiOption('', 'Select Approver 2');
     $approver_2->setAttrib('onchange', 'displayapprovingauthority(this)');
     $approver_2->setRegisterInArrayValidator(false);
     $approver_3 = new Zend_Form_Element_Select('approver_3');
     $approver_3->setLabel("Approver 3");
     $approver_3->setAttrib('class', 'selectoption');
     $approver_3->addMultiOption('', 'Select Approver 3');
     $approver_3->setRegisterInArrayValidator(false);
     $cc_mail_recievers = new Zend_Form_Element_Multiselect('cc_mail_recievers');
     $cc_mail_recievers->setLabel("Request Viewers");
     $cc_mail_recievers->setAttrib('class', 'selectoption');
     $cc_mail_recievers->setRegisterInArrayValidator(false);
     $attachment = new Zend_Form_Element_Radio('attachment');
     $attachment->setLabel("Attachment");
     $attachment->addMultiOptions(array('1' => 'Yes', '0' => 'No'));
     $attachment->setSeparator('');
     $attachment->setValue(0);
     $attachment->setRegisterInArrayValidator(false);
     $description = new Zend_Form_Element_Textarea('description');
     $description->setLabel("Description");
     $description->setAttrib('rows', 10);
     $description->setAttrib('cols', 50);
     $description->setAttrib('maxlength', '200');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $businessunit_id, $department_id, $description, $service_desk_flag, $service_desk_id, $request_recievers, $approvingauthority, $approver_1, $approver_2, $approver_3, $cc_mail_recievers, $attachment, $submit));
     $this->setElementDecorators(array('ViewHelper'));
//.........这里部分代码省略.........
开发者ID:lukkyrich,项目名称:sentrifugo,代码行数:101,代码来源:servicedeskconf.php

示例2: createFormElements

 /**
  * Функция создание формы 
  * @param type $objForm объект формы 
  * @param type $elementsForm элементы в  виде массива
  * @return type объект формы
  */
 protected function createFormElements($objForm, $elementsForm)
 {
     foreach ($elementsForm as $key => $value) {
         // определяем тип по умолчанию
         $type = !empty($value['type']) ? $value['type'] : 'text';
         // массив с опциями
         $params = array();
         if ($type !== 'hidden') {
             $params['label'] = !empty($value['label']) ? $value['label'] : die('Не оределлен атрибут label!');
         }
         $params['decorators'] = !empty($value['decorators']) ? $value['decorators'] : $this->elementDecorators();
         if (!empty($value['multiOptions'])) {
             $params['multiOptions'] = $value['multiOptions'];
         }
         $value['required'] = !empty($value['required']) ? $value['required'] : true;
         $value['attribs'] = !empty($value['attribs']) ? $value['attribs'] : array('class' => 'form-control');
         $value['filters'] = !empty($value['filters']) ? $value['filters'] : '';
         $value['validators'] = !empty($value['validators']) ? $value['validators'] : '';
         // присваевыем стандартные фильтры и валидаторы
         if (empty($value['filters'])) {
             $stringTrim = new Zend_Filter_StringTrim();
             $stripTags = new Zend_Filter_StripTags();
             $value['filters'] = array('stringTrim' => $stringTrim, 'stripTags' => $stripTags);
         }
         if (empty($value['validators'])) {
             $alnum = new Zend_Validate_Alnum();
             $alnum->setMessage('Только буквы и цыфры!');
             $notEmpty = new Zend_Validate_NotEmpty();
             $notEmpty->setMessage('Поле обязательно для заполнения', 'isEmpty');
             $value['validators'] = array('alnum' => $alnum, 'notEmpty' => $notEmpty);
         }
         // провеки на тип если нужен новый то надо добавить по аналогии
         switch ($type) {
             case 'text':
                 $elem = new Zend_Form_Element_Text($key);
                 break;
             case 'textarea':
                 $elem = new Zend_Form_Element_Textarea($key);
                 break;
             case 'select':
                 $elem = new Zend_Form_Element_Select($key);
                 break;
             case 'password':
                 $elem = new Zend_Form_Element_Password($key);
                 break;
             case 'hidden':
                 $elem = new Zend_Form_Element_Hidden($key);
                 break;
             case 'radio':
                 $elem = new Zend_Form_Element_Radio($key);
                 break;
         }
         // присваиваем атрибуты
         if (!empty($value['attribs'])) {
             foreach ($value['attribs'] as $k => $val) {
                 $params[$k] = $val;
             }
         }
         // присваиваем опции
         if (!empty($elem)) {
             $elem->setOptions($params);
         }
         // добавляем валидаторы
         if (!empty($value['validators']) && $type !== 'hidden') {
             foreach ($value['validators'] as $val) {
                 $elem->addValidator($val);
             }
         }
         // добавляем фильтры
         if (!empty($value['filters']) && $type !== 'hidden') {
             foreach ($value['filters'] as $val) {
                 $elem->addFilter($val);
             }
         }
         // вот тут писец
         if (!empty($value['required']) && $type !== 'hidden') {
             $elem->setRequired(TRUE);
         }
         // добавляем элемент на форму
         $objForm->addElement($elem);
     }
     // добавляем кнопку
     $objForm->addElement('submit', 'submit', array('label' => $this->buttonLabel, 'decorators' => $this->buttonDecorators(), 'class' => 'btn btn-default'));
     return $objForm;
 }
开发者ID:MichaelGogeshvili,项目名称:strap,代码行数:91,代码来源:Form.php

示例3: init

 public function init()
 {
     $this->setMethod('post');
     //$this->setAttrib('action',DOMAIN.'language/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'appraisalconfig');
     $id = new Zend_Form_Element_Hidden('id');
     $postid = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
     $businessunit_id = new Zend_Form_Element_Select('businessunit_id');
     $businessunit_id->setLabel("Business Unit");
     $businessunit_id->setAttrib('class', 'selectoption');
     if ($postid == '') {
         $businessunit_id->setAttrib('onchange', 'displayDept(this)');
         $bunitdata = $this->bunitdata;
         if (!empty($bunitdata)) {
             $businessunit_id->addMultiOptions(array('' => 'Select Business unit', '0' => 'No Business Unit'));
             foreach ($bunitdata as $data) {
                 $businessunit_id->addMultiOption($data['id'], $data['unitname']);
             }
         } else {
             $businessunit_id->addMultiOptions(array('' => 'Select Business unit'));
         }
     } else {
         $businessunit_id->addMultiOptions(array('' => 'Select Business unit'));
     }
     $businessunit_id->setRegisterInArrayValidator(false);
     $businessunit_id->setRequired(true);
     $businessunit_id->addValidator('NotEmpty', false, array('messages' => 'Please select business unit.'));
     $department_id = new Zend_Form_Element_Select('department_id');
     $department_id->setLabel("Department");
     $department_id->setAttrib('class', 'selectoption');
     $department_id->addMultiOption('', 'Select Department');
     if ($postid == '') {
         $department_id->setAttrib('onchange', 'displayDept(this)');
     }
     $department_id->setRegisterInArrayValidator(false);
     $performance_app_flag = new Zend_Form_Element_Radio('performance_app_flag');
     $performance_app_flag->setLabel("Applicability");
     $performance_app_flag->setAttrib('onclick', 'checkimplementfun(this)');
     $performance_app_flag->addMultiOptions(array('1' => 'Business unit wise', '0' => 'Department wise'));
     $performance_app_flag->setSeparator('');
     $performance_app_flag->setValue(1);
     $performance_app_flag->setRegisterInArrayValidator(false);
     $performance_app_flag->setRequired(true);
     $performance_app_flag->addValidator('NotEmpty', false, array('messages' => 'Please select applicability.'));
     $appraisal_mode = new Zend_Form_Element_Select('appraisal_mode');
     $appraisal_mode->setLabel("Appraisal Mode");
     $appraisal_mode->setAttrib('class', 'selectoption');
     $appraisal_mode->addMultiOptions(array('' => 'Select appraisal mode', 'Quarterly' => 'Quarterly', 'Half-yearly' => 'Half-yearly', 'Yearly' => 'Yearly'));
     $appraisal_mode->setRegisterInArrayValidator(false);
     $appraisal_mode->setRequired(true);
     $appraisal_mode->addValidator('NotEmpty', false, array('messages' => 'Please select appraisal mode.'));
     $appraisal_ratings = new Zend_Form_Element_Select('appraisal_ratings');
     $appraisal_ratings->setLabel("Appraisal Ratings");
     $appraisal_ratings->setAttrib('class', 'selectoption');
     $appraisal_ratings->addMultiOptions(array('' => 'Select ratings', '1' => '1-5', '2' => '1-10'));
     $appraisal_ratings->setRegisterInArrayValidator(false);
     $appraisal_ratings->setRequired(true);
     $appraisal_ratings->addValidator('NotEmpty', false, array('messages' => 'Please select appraisal ratings.'));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $businessunit_id, $performance_app_flag, $department_id, $appraisal_mode, $appraisal_ratings, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
开发者ID:lukkyrich,项目名称:sentrifugo,代码行数:65,代码来源:Appraisalconfig.php

示例4: init

 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('action', BASE_URL . 'timemanagement/expenses/edit');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'expensecategory');
     $id = new Zend_Form_Element_Hidden('id');
     $client = new Zend_Form_Element_Select('client_id');
     $client->addMultiOption('', 'Select Client');
     $client->setRegisterInArrayValidator(false);
     $client->setAttrib('onchange', 'loadProjects(this)');
     $client->setRequired(true);
     $client->addValidator('NotEmpty', false, array('messages' => 'Please select Client.'));
     $client->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_clients', 'field' => 'id', 'exclude' => 'is_active = 1')));
     $client->getValidator('Db_RecordExists')->setMessage('Selected Client is inactivated.');
     $project = new Zend_Form_Element_Select('project_id');
     $project->addMultiOption('', 'Select Project');
     $project->setRegisterInArrayValidator(false);
     $project->setRequired(true);
     $project->addValidator('NotEmpty', false, array('messages' => 'Please select Project.'));
     $project->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_projects', 'field' => 'id', 'exclude' => 'is_active = 1')));
     $project->getValidator('Db_RecordExists')->setMessage('Selected Project is inactivated.');
     $category = new Zend_Form_Element_Select('expense_cat_id');
     $category->addMultiOption('', 'Select Category');
     $category->setRegisterInArrayValidator(false);
     $category->setRequired(true);
     $category->addValidator('NotEmpty', false, array('messages' => 'Please select Category.'));
     $category->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_expense_categories', 'field' => 'id', 'exclude' => 'is_active = 1')));
     $category->getValidator('Db_RecordExists')->setMessage('Selected Category is inactivated.');
     $expenseDate = new ZendX_JQuery_Form_Element_DatePicker('expense_date');
     $expenseDate->setOptions(array('class' => 'brdr_none'));
     //$date_of_leaving->setAttrib('onchange', 'validatejoiningdate(this)');
     $expenseDate->setAttrib('readonly', 'true');
     $expenseDate->setAttrib('onfocus', 'this.blur()');
     $expenseAmount = new Zend_Form_Element_Text('expense_amount');
     $expenseAmount->setAttrib('maxLength', 8);
     $expenseAmount->setLabel("Unit Price");
     $expenseAmount->addValidator("regex", true, array('pattern' => '/^[1-9]\\d{1,4}(\\.\\d{1,2})?$/', 'messages' => array('regexNotMatch' => 'Please enter valid Amount.')));
     $note = new Zend_Form_Element_Text('note');
     $note->setAttrib('maxLength', 200);
     $note->setLabel("Note");
     $billable = new Zend_Form_Element_Radio('is_billable');
     $billable->setLabel("Type");
     $billable->addMultiOptions(array('1' => 'Yes', '0' => 'No'));
     $billable->setSeparator('');
     $billable->setValue('billable');
     $billable->setRegisterInArrayValidator(false);
     $billable->setRequired(true);
     $billable->addValidator('NotEmpty', false, array('messages' => 'Please select Type.'));
     /*
     client_idbigint(20) unsigned NOT NULL
     project_idbigint(20) unsigned NOT NULL
     expense_cat_idint(10) unsigned NOT NULL
     expense_datetimestamp NOT NULL
     expense_amountdecimal(8,2) unsigned NOT NULL
     notevarchar(200) NULL
     is_billabletinyint(1) unsigned NOT NULL
     receipt_filevarchar(200) NULL
     expense_statusenum('saved','submitted','approved','rejected') NULL
     status_update_datetimestamp NOT NULL
     status_update_byint(11) NULL
     reject_notevarchar(200) NULL
     */
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $client, $project, $category, $expenseDate, $expenseAmount, $note, $billable, $submit));
     $this->setElementDecorators(array('ViewHelper'));
     $this->setElementDecorators(array('UiWidgetElement'), array('expense_date'));
 }
开发者ID:lukkyrich,项目名称:sentrifugo,代码行数:70,代码来源:Expenses.php

示例5: init

 public function init()
 {
     if (isset($this->advertisement)) {
         $user = Advertisement::getUser($this->advertisement->id);
         $element = new Zend_Form_Element_Hidden('id');
         $element->setValue($this->advertisement->id);
         $this->addElement($element);
         $element = new Zend_Form_Element_Hidden('password');
         $element->setValue($this->password);
         $this->addElement($element);
         $this->setAction('/' . strtolower($this->city->name) . '/bulletin/update');
     } else {
         $this->setAction('/' . strtolower($this->city->name) . '/bulletin/create');
     }
     $element = new Zend_Form_Element_Hidden('city');
     $element->setValue($this->city->id);
     $this->addElement($element);
     $this->setMethod('POST');
     $this->setName('createAdForm');
     $element = new Zend_Form_Element_Text('name');
     $element->setLabel('怎么称呼您');
     $element->setDescription('必填,中英文都可,2到30个字');
     $element->setRequired(true);
     //$element->addValidator(new Zend_Validate_StringLength(2,30));
     if (isset($user)) {
         $element->setValue($user->name);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('email');
     $element->setLabel('您的Email');
     $element->setRequired(true);
     $element->addValidator(new Zend_Validate_EmailAddress());
     $element->addValidator('NotEmpty');
     $element->setDescription('必填,将不会显示在您的帖子里');
     if (isset($user)) {
         $element->setValue($user->email);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('mobile');
     $element->setLabel('您的手机号');
     $element->addFilter(new Zend_Filter_HtmlEntities());
     $element->addFilter(new Zend_Filter_StripTags());
     $element->setDescription('方便其他用户联系您');
     if (isset($user)) {
         $element->setValue($user->mobile);
     }
     $this->addElement($element);
     $this->addDisplayGroup(array('name', 'email', 'mobile'), 'aboutYou');
     $this->getDisplayGroup('aboutYou')->removeDecorator('DtDdWrapper');
     // radio box
     $element = new Zend_Form_Element_Radio('type');
     $element->addMultiOptions(array('lease' => '供', 'want' => '求'))->removeDecorator('Label');
     $element->setSeparator('')->setValue(Advertisement::LEASE);
     if (isset($this->advertisement)) {
         $element->setValue($this->advertisement->type);
     }
     $this->addElement($element);
     // category
     $element = new Zend_Form_Element_Checkbox("isBusiness");
     $element->setLabel('是商铺/店面吗?');
     if (isset($this->advertisement) && $this->advertisement->category_id == Category::SHOP) {
         $element->setValue(1);
     } else {
         $element->setValue(0);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('title');
     $element->setLabel('帖子标题');
     $element->setRequired(true);
     $element->addValidator('NotEmpty');
     //$element->addValidator(new Zend_Validate_StringLength(10,30));
     $element->setDescription('必填,5-100字,概括题目,突出重点');
     if (isset($this->advertisement)) {
         $element->setValue($this->advertisement->title);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('address');
     $element->setLabel('房子的住址');
     $element->setDescription('必填,以便用户在地图上方便的找到');
     if (isset($this->advertisement)) {
         $element->setValue($this->advertisement->address);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('rent');
     $element->setLabel('租金');
     if (isset($this->advertisement)) {
         $element->setValue($this->advertisement->rent);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Select('currency');
     //$element->setLabel("货币");
     $element->addMultiOptions(Currency::getAvailableCurrencyAsArray());
     if (isset($this->advertisement)) {
         $element->setValue(Advertisement::getCurrency($this->advertisement)->id);
     } else {
         $element->setValue(127);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Radio('rent_measurement');
     $element->addMultiOptions(array('month' => '每月', 'day' => '每日'))->setSeparator('')->setDescription('必填')->removeDecorator('Label');
//.........这里部分代码省略.........
开发者ID:BGCX262,项目名称:zufangzi-svn-to-git,代码行数:101,代码来源:CreateOrUpdatePost.php

示例6: init

 public function init()
 {
     $this->setMethod('post');
     $this->setAttrib('id', 'formid');
     $this->setAttrib('name', 'identitydocuments');
     $id = new Zend_Form_Element_Hidden('id');
     /*$identitydocuments = new Zend_Form_Element_MultiCheckbox('identitydoc');
     		$identitydocuments->setLabel('Identity Documents');
     		$identitydocuments->setMultiOptions(array(
                                	'1'=>'Passport',
     							'2'=>'SSN',
     							'3'=>'Aadhaar',
                                 '4'=>'Pan Card',
                                 '5'=>'Driving License',
     							));
     		$identitydocuments->setRequired(true);
     		$identitydocuments->addValidator('NotEmpty', false, array('messages' => 'Please select at least one identity document type.'));
     		$identitydocuments->setSeparator(PHP_EOL);	
     		
     		$othercheck = new Zend_Form_Element_Checkbox('othercheck');
     		$othercheck->setLabel('Other Documents');
     		$othercheck->setAttrib('onclick', 'displayotherdocumentdiv(this)');
     	 
     		
     		$otherdocument = new Zend_Form_Element_Text('otherdocument');
     		$otherdocument->setAttrib('maxlength',50);
     		$otherdocument->setAttrib('onblur', 'validate_otherdocument(this)');
     		$otherdocument->setLabel('Document Name');
     		$otherdocument->addValidator("regex",true,array(
     							'pattern'=> '/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9\-\s]*)$/',
                                'messages'=>array(
                                    'regexNotMatch'=>'Please enter valid document name.'
                                )
             	));*/
     $documentname = new Zend_Form_Element_Text('document_name');
     $documentname->setAttrib('maxlength', 50);
     $documentname->setLabel('Document Name');
     $documentname->setRequired(true);
     $documentname->addValidator('NotEmpty', false, array('messages' => 'Please enter document name.'));
     $documentname->addValidator("regex", true, array('pattern' => '/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9\\-\\s]*)$/', 'messages' => array('regexNotMatch' => 'Please enter valid document name.')));
     $documentname->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'main_identitydocuments', 'field' => 'document_name', 'exclude' => 'id!="' . Zend_Controller_Front::getInstance()->getRequest()->getParam('id') . '" AND isactive=1')));
     $documentname->getValidator('Db_NoRecordExists')->setMessage('Document name already exists.');
     $mandatory = new Zend_Form_Element_Radio('mandatory');
     $mandatory->setLabel("Mandatory");
     $mandatory->addMultiOptions(array('1' => 'Yes', '0' => 'No'));
     $mandatory->setRequired(true);
     $mandatory->addValidator('NotEmpty', false, array('messages' => 'Please select mandatory.'));
     $mandatory->setSeparator('');
     $mandatory->setValue(0);
     $mandatory->setRegisterInArrayValidator(false);
     $expiry = new Zend_Form_Element_Radio('expiry');
     $expiry->setLabel("Expiry");
     $expiry->addMultiOptions(array('1' => 'Yes', '0' => 'No'));
     $expiry->setRequired(true);
     $expiry->addValidator('NotEmpty', false, array('messages' => 'Please select expiry.'));
     $expiry->setSeparator('');
     $expiry->setValue(0);
     $expiry->setRegisterInArrayValidator(false);
     $description = new Zend_Form_Element_Textarea('description');
     $description->setLabel("Description");
     $description->setAttrib('rows', 10);
     $description->setAttrib('cols', 50);
     $description->setAttrib('maxlength', '200');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $submit->setLabel('Save');
     $this->addElements(array($id, $documentname, $mandatory, $expiry, $description, $submit));
     $this->setElementDecorators(array('ViewHelper'));
 }
开发者ID:rajbrt,项目名称:sentrifugo,代码行数:69,代码来源:identitydocuments.php


注:本文中的Zend_Form_Element_Radio::addValidator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。