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


PHP sfForm::setValidator方法代码示例

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


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

示例1: embedWidgetIntoForm

 public function embedWidgetIntoForm(sfForm $form)
 {
     $widgetSchema = $form->getWidgetSchema();
     $validatorSchema = $form->getValidatorSchema();
     $widgetSchema['from_date'] = new ohrmWidgetDatePicker(array(), array('id' => 'from_date'));
     $widgetSchema['from_date']->setLabel("From ");
     $form->setValidator('from_date', new sfValidatorDate());
     $widgetSchema['to_date'] = new ohrmWidgetDatePicker(array(), array('id' => 'to_date'));
     $widgetSchema['to_date']->setLabel("To ");
     $form->setValidator('to_date', new sfValidatorDate());
     $validatorSchema->setPostValidator(new sfValidatorSchemaCompare('from_date', sfValidatorSchemaCompare::LESS_THAN_EQUAL, 'to_date', array('throw_global_error' => true), array('invalid' => 'The from date ("%left_field%") must be before the to date ("%right_field%")')));
     return $form;
 }
开发者ID:THM068,项目名称:orangehrm,代码行数:13,代码来源:ohrmWidgetJQueryDateRange.php

示例2: replaceValidators

 public static function replaceValidators(sfForm $form)
 {
     foreach ($form->getWidgetSchema()->getFields() as $name => $widget) {
         if ($widget instanceof mtWidgetFormInputDate) {
             $form->setValidator($name, self::getDateValidator());
         } elseif ($widget instanceof sfWidgetFormFilterDate) {
             $form->getValidator($name)->setOption("from_date", self::getDateValidator(array("required" => false)));
             $form->getValidator($name)->setOption("to_date", self::getDateValidator(array("required" => false)));
         }
         if ($name == "attachment") {
             $form->setValidator($name, new sfValidatorFile(array("required" => false, "path" => sfConfig::get("sf_upload_dir"))));
         } elseif ($name == "email") {
             $form->setValidator($name, new sfValidatorEmail());
         }
     }
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:16,代码来源:pmValidatorFactory.class.php

示例3: embedWidgetIntoForm

 /**
  * Embeds this widget into the form.
  * @param sfForm $form
  */
 public function embedWidgetIntoForm(sfForm &$form)
 {
     $widgetSchema = $form->getWidgetSchema();
     $widgetSchema[$this->attributes['id']] = $this;
     $label = ucwords(str_replace("_", " ", $this->attributes['id']));
     $widgetSchema[$this->attributes['id']]->setLabel($label);
     $form->setValidator($this->attributes['id'], new sfValidatorPass());
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:12,代码来源:ohrmWidgetInputCheckbox.php

示例4: embedForm

 /**
  * Just to make sure every time a form is embedded, the 'remove' widgets
  * are added. They are needed in the deleting process
  */
 public function embedForm($name, sfForm $form, $decorator = null)
 {
     if ($form instanceof sfFormDoctrine) {
         $form->setWidget('remove', new sfWidgetFormInputHidden(array(), array('class' => 'remove')));
         $form->setValidator('remove', new sfValidatorPass());
     }
     parent::embedForm($name, $form, $decorator);
 }
开发者ID:solutema,项目名称:siwapp-sf1,代码行数:12,代码来源:FormsContainer.class.php

示例5: embedWidgetIntoForm

 /**
  * Embeds this widget into the form. Sets label and validator for this widget.
  * @param sfForm $form
  */
 public function embedWidgetIntoForm(sfForm &$form)
 {
     $widgetSchema = $form->getWidgetSchema();
     $widgetSchema[$this->attributes['id']] = $this;
     $label = ucwords(str_replace("_", " ", $this->attributes['id']));
     $validator = new sfValidatorChoice(array('choices' => array_keys($this->subDivisionList)));
     if ($this->attributes['required'] == "true") {
         $label .= "<span class='required'> * </span>";
     }
     $widgetSchema[$this->attributes['id']]->setLabel($label);
     $form->setValidator($this->attributes['id'], $validator);
 }
开发者ID:rabbitdigital,项目名称:HRM,代码行数:16,代码来源:ohrmWidgetSubDivisionList.php

示例6: embedWidgetIntoForm

 /**
  * Embeds this widget into the form. Sets label and validator for this widget.
  * @param sfForm $form
  */
 public function embedWidgetIntoForm(sfForm &$form)
 {
     $widgetSchema = $form->getWidgetSchema();
     $widgetSchema[$this->attributes['id']] = $this;
     $label = ucwords(str_replace("_", " ", $this->attributes['id']));
     $validator = new sfValidatorString();
     if ($this->attributes['required'] == "true") {
         $label .= "<span class='required'> * </span>";
         $validator = new sfValidatorString(array('required' => true), array('required' => 'No employees added to the system'));
     }
     $widgetSchema[$this->attributes['id']]->setLabel($label);
     $form->setValidator($this->attributes['id'], $validator);
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:17,代码来源:ohrmWidgetEmployeeList.php

示例7: embedWidgetIntoForm

 /**
  * Embeds this widget into the form. Sets label and validator for this widget.
  * @param sfForm $form
  */
 public function embedWidgetIntoForm(sfForm &$form)
 {
     $widgetSchema = $form->getWidgetSchema();
     $widgetSchema[$this->attributes['id']] = $this;
     $label = __(ucwords(str_replace("_", " ", $this->attributes['id'])));
     $validator = new sfValidatorString(array('required' => false));
     if ($this->attributes['required'] == "true") {
         $label .= "<span class='required'> * </span>";
         $validator = new sfValidatorString(array('required' => true), array('required' => 'Add a project to view'));
     }
     $widgetSchema[$this->attributes['id']]->setLabel($label);
     $form->setValidator($this->attributes['id'], $validator);
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:17,代码来源:ohrmWidgetProjectListWithAllOption.php

示例8: embedWidgetIntoForm

 /**
  * Embeds this widget into the form. Sets label and validator for this widget.
  * @param sfForm $form
  */
 public function embedWidgetIntoForm(sfForm &$form)
 {
     $requiredMess = 'Select a gender type';
     $widgetSchema = $form->getWidgetSchema();
     $widgetSchema[$this->attributes['id']] = $this;
     $label = ucwords(str_replace("_", " ", $this->attributes['id']));
     $validator = new sfValidatorString();
     if (isset($this->attributes['required']) && $this->attributes['required'] == "true") {
         $label .= "<span class='required'> * </span>";
         $validator = new sfValidatorString(array('required' => true), array('required' => $requiredMess));
     }
     $widgetSchema[$this->attributes['id']]->setLabel($label);
     $form->setValidator($this->attributes['id'], $validator);
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:18,代码来源:ohrmReportWidgetGenderDropDown.php

示例9: embedWidgetIntoForm

 /**
  * Embeds this widget into the form. Sets label and validator for this widget.
  * @param sfForm $form
  */
 public function embedWidgetIntoForm(sfForm &$form)
 {
     $widgetSchema = $form->getWidgetSchema();
     $widgetSchema[$this->attributes['id']] = $this;
     $label = ucwords(str_replace("_", " ", $this->attributes['id']));
     $required = false;
     if (isset($this->attributes['required']) && $this->attributes['required'] == "true") {
         $label .= "<span class='required'> * </span>";
         $required = true;
     }
     $requiredMess = __(ValidationMessages::REQUIRED);
     $validator = new sfValidatorString(array('required' => $required), array('required' => $requiredMess));
     $widgetSchema[$this->attributes['id']]->setLabel($label);
     $form->setValidator($this->attributes['id'], $validator);
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:19,代码来源:ohrmReportWidgetSkillDropDown.php

示例10: embedWidgetIntoForm

 /**
  * Embeds this widget into the form. Sets label and validator for this widget.
  * @param sfForm $form
  */
 public function embedWidgetIntoForm(sfForm &$form)
 {
     $userObj = sfContext::getInstance()->getUser()->getAttribute("user");
     $projectList = $userObj->getActiveProjectList();
     $requiredMess = __('Select a project');
     if ($projectList == null) {
         $requiredMess = __("No Projects Defined");
     }
     $widgetSchema = $form->getWidgetSchema();
     $widgetSchema[$this->attributes['id']] = $this;
     $label = __(ucwords(str_replace("_", " ", $this->attributes['id'])));
     $validator = new sfValidatorString();
     if ($this->attributes['required'] == "true") {
         $label .= "<span class='required'> * </span>";
         $validator = new sfValidatorString(array('required' => true), array('required' => $requiredMess));
     }
     $widgetSchema[$this->attributes['id']]->setLabel($label);
     $form->setValidator($this->attributes['id'], $validator);
 }
开发者ID:THM068,项目名称:orangehrm,代码行数:23,代码来源:ohrmWidgetProjectList.php

示例11: configureJCropValidators

 /**
  * Takes a form and configures each image's widget.
  * 
  * This is one of only 2 methods the user needs to call manually (the other being configureJCropWidgets)
  * Should be called from the form's configure() method
  * 
  * @param sfForm $form
  */
 public function configureJCropValidators($form)
 {
     foreach ($this->_options['images'] as $fieldName) {
         $form->setValidator($fieldName . '_delete', new sfValidatorPass());
         $form->setValidator($fieldName, new sfValidatorFile(array('required' => false, 'path' => $this->getImageDir(), 'mime_types' => 'web_images'), array('mime_types' => 'Unsupported image type (%mime_type%)')));
     }
 }
开发者ID:retrofox,项目名称:Huemul,代码行数:15,代码来源:JCroppable.php

示例12: addImageField

 /**
  * Add a validated image upload field to a form.
  * 
  * @param sfForm $form        Form to modify
  * @param string $field_name  Name of the image upload field, default 'image'  
  */
 public static function addImageField($form, $field_name = 'image')
 {
     $form->setWidget($field_name, new sfWidgetFormInputFile());
     $form->setValidator($field_name, new sfValidatorImageFile(self::getValidatorOptions(), self::getValidatorMessages()));
 }
开发者ID:nixilla,项目名称:sfImagePoolPlugin,代码行数:11,代码来源:sfImagePoolUtil.class.php

示例13: correctValidators

 /**
  * Replacing validators with their up-to-date equivalent from an embedded form.
  *
  * @param  sfForm $form Form instance on which to replace validators
  *
  * @return sfValidatorSchema
  */
 protected function correctValidators($form)
 {
     foreach ($form->getEmbeddedForms() as $field => $embed) {
         if ($form->getValidator($field) instanceof sfValidatorSchema) {
             foreach ($embed->getValidatorSchema()->getFields() as $name => $validator) {
                 if (!$form->getValidator($field)->offsetExists($name)) {
                     $embed->getValidatorSchema()->offsetUnset($name);
                 }
             }
             $form->setValidator($field, $this->correctValidators($embed));
         }
     }
     return $form->getValidatorSchema();
 }
开发者ID:AUTOPLANNING,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:21,代码来源:sfDoctrineDynamicFormRelations.class.php

示例14: changeThemeWidget

 /**
  * Change theme widget to be dropdown of themes
  *
  * @param sfForm $form 
  * @return void
  */
 public static function changeThemeWidget(sfForm $form)
 {
     $array = self::getThemeWidgetAndValidator();
     $form->setWidget('theme', $array['widget']);
     $form->setValidator('theme', $array['validator']);
 }
开发者ID:RafalJachimczyk,项目名称:sympal,代码行数:12,代码来源:sfSympalFormToolkit.class.php

示例15: embedWidgetIntoForm

 /**
  * Embeds this widget into the form. Sets label and validator for this widget.
  * @param sfForm $form
  */
 public function embedWidgetIntoForm(sfForm &$form)
 {
     $activeProjectFound = false;
     $userRoleManager = sfContext::getInstance()->getUserRoleManager();
     $projectList = $userRoleManager->getAccessibleEntities('Project');
     foreach ($projectList as $project) {
         if ($project->getIsDeleted() != 0) {
             $activeProjectFound = true;
             break;
         }
     }
     $requiredMess = __('Select a project');
     if (!$activeProjectFound) {
         $requiredMess = __("No Projects Defined");
     }
     $widgetSchema = $form->getWidgetSchema();
     $widgetSchema[$this->attributes['id']] = $this;
     $label = __(ucwords(str_replace("_", " ", $this->attributes['id'])));
     $validator = new sfValidatorString();
     if ($this->attributes['required'] == "true") {
         $label .= "<span class='required'> * </span>";
         $validator = new sfValidatorString(array('required' => true), array('required' => $requiredMess));
     }
     $widgetSchema[$this->attributes['id']]->setLabel($label);
     $form->setValidator($this->attributes['id'], $validator);
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:30,代码来源:ohrmWidgetProjectList.php


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