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


PHP sfForm::getValidator方法代码示例

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


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

示例1: 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

示例2: 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

示例3: getFormFieldContainerClass

  public function getFormFieldContainerClass(sfForm $form, $name)
  {
    $class = array('form-element');

    $attributes = array();

    if (isset($form[$name]))
    {
      $widget = $form->getWidget($name);
      $validator = $form->getValidator($name);

      switch (true)
      {
        case $validator->getOption('required') === true:
          $class[] = 'required';
          break;

        default:
          $class[] = sfInflector::underscore(str_replace('sfWidgetForm', '', get_class($widget)));
          break;
      }
    }

    return implode(' ', $class);
  }
开发者ID:romankallweit,项目名称:swingmachine,代码行数:25,代码来源:sfHadoriGenerator.class.php


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