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


PHP BaseControl::addRule方法代码示例

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


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

示例1: addConditions

 /**
  * Add default conditions.
  * Supports: required, min/maxLength, min, max
  *
  * @param \Nette\Forms\Controls\BaseControl $input
  * @param array $conditions
  */
 protected function addConditions(\Nette\Forms\Controls\BaseControl $input, array $conditions)
 {
     foreach ($conditions as $key => $value) {
         switch ($key) {
             case 'required':
                 $input->setRequired();
                 break;
             case 'maxLength':
                 $input->addRule(Builder\EntityForm::MAX_LENGTH, null, $value);
                 break;
             case 'minLength':
                 $input->addRule(Builder\EntityForm::MIN_LENGTH, null, $value);
                 break;
             default:
                 break;
         }
     }
     if (isset($conditions['min']) || isset($conditions['max'])) {
         $input->addRule(Builder\EntityForm::RANGE, null, array(isset($conditions['min']) ? $conditions['min'] : null, isset($conditions['max']) ? $conditions['max'] : null));
     }
 }
开发者ID:voda,项目名称:formbuilder,代码行数:28,代码来源:DefaultMapper.php

示例2: addRule

 public function addRule($operation, $message = NULL, $arg = NULL)
 {
     if ($operation === Form::FLOAT) {
         $this->addFilter(callback(__CLASS__, 'filterFloat'));
     }
     return parent::addRule($operation, $message, $arg);
 }
开发者ID:bazo,项目名称:Tatami,代码行数:7,代码来源:TextBase.php

示例3: addRule

 public function addRule($validator, $message = NULL, $arg = NULL)
 {
     if ($validator === Form::LENGTH || $validator === Form::MAX_LENGTH) {
         $tmp = is_array($arg) ? $arg[1] : $arg;
         if (is_scalar($tmp)) {
             $this->control->maxlength = isset($this->control->maxlength) ? min($this->control->maxlength, $tmp) : $tmp;
         }
     }
     return parent::addRule($validator, $message, $arg);
 }
开发者ID:luminousinfoways,项目名称:pccfoas,代码行数:10,代码来源:TextBase.php

示例4: addRule

 public function addRule($operation, $message = NULL, $arg = NULL)
 {
     if ($operation === Form::FLOAT) {
         $this->addFilter(array(__CLASS__, 'filterFloat'));
     } elseif ($operation === Form::LENGTH || $operation === Form::MAX_LENGTH) {
         $tmp = is_array($arg) ? $arg[1] : $arg;
         $this->control->maxlength = is_scalar($tmp) ? $tmp : NULL;
     }
     return parent::addRule($operation, $message, $arg);
 }
开发者ID:ppwalks33,项目名称:cleansure,代码行数:10,代码来源:TextBase.php

示例5: addRule

 /**
  * {@inheritdoc}
  */
 public function addRule($validator, $message = NULL, $arg = NULL)
 {
     return $this->wrappedControl->addRule($validator, $message, $arg);
 }
开发者ID:mike227,项目名称:n-forms,代码行数:7,代码来源:ApplyButtonWrapper.php

示例6: addRule

 public function addRule($operation, $message = null, $arg = null)
 {
     if ($operation === \Nette\Forms\Form::RANGE) {
         $this->range['min'] = $this->normalizeDate($arg[0]);
         $this->range['max'] = $this->normalizeDate($arg[1]);
         $operation = __CLASS__ . '::validateDateInputRange';
         $arg[0] = $this->formatDate($arg[0]);
         $arg[1] = $this->formatDate($arg[1]);
     } elseif ($operation === \Nette\Forms\Form::VALID) {
         $operation = __CLASS__ . '::validateDateInputValid';
     }
     return parent::addRule($operation, $message, $arg);
 }
开发者ID:pt24,项目名称:DateInput,代码行数:13,代码来源:DateInput.php

示例7: addRule

 public function addRule($operation, $message = NULL, $arg = NULL)
 {
     if ($operation === Form::LENGTH || $operation === Form::MAX_LENGTH) {
         $tmp = is_array($arg) ? $arg[1] : $arg;
         $this->control->maxlength = is_scalar($tmp) ? $tmp : NULL;
     }
     return parent::addRule($operation, $message, $arg);
 }
开发者ID:Johnik010,项目名称:rezervace,代码行数:8,代码来源:TextBase.php

示例8: addNetteRule

 /**
  * @param BaseControl $control
  * @param string      $rule
  * @param string      $message
  * @param mixed       $arg
  */
 protected function addNetteRule(BaseControl $control, $rule, $message, $arg = NULL)
 {
     $control->addRule($rule, $message, $arg);
 }
开发者ID:mike227,项目名称:n-forms,代码行数:10,代码来源:ControlConstraintsMapper.php

示例9:

getControl(){$control=parent::getControl();foreach($this->getRules()as$rule){if($rule->type===Nette\Forms\Rule::VALIDATOR&&!$rule->isNegative&&($rule->operation===Form::LENGTH||$rule->operation===Form::MAX_LENGTH)){$control->maxlength=is_array($rule->arg)?$rule->arg[1]:$rule->arg;}}if($this->emptyValue!==''){$control->data('nette-empty-value',$this->translate($this->emptyValue));}return$control;}function
addRule($operation,$message=NULL,$arg=NULL){if($operation===Form::FLOAT){$this->addFilter(callback(__CLASS__,'filterFloat'));}return
parent::addRule($operation,$message,$arg);}static
开发者ID:JanTvrdik,项目名称:NetteExtras,代码行数:3,代码来源:loader.php

示例10: addRule

 public function addRule($operation, $message = null, $arg = null)
 {
     if ($operation === Form::FLOAT) {
         $this->addFilter(array(__CLASS__, 'filterFloat'));
     }
     return parent::addRule($operation, $message, $arg);
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:7,代码来源:TextBase.php

示例11: addRule

 /**
  * Adds a validation rule.
  * @param  mixed      rule type
  * @param  string     message to display for invalid data
  * @param  mixed      optional rule arguments
  * @return BaseControl  provides a fluent interface
  */
 public function addRule($operation, $message = NULL, $arg = NULL)
 {
     if ($operation === \Nette\Forms\Form::RANGE) {
         $this->range['min'] = $arg[0];
         $this->range['max'] = $arg[1];
         $operation = ':dateInputRange';
         $arg[0] = $this->formatDate($arg[0]);
         $arg[1] = $this->formatDate($arg[1]);
     } elseif ($operation === \Nette\Forms\Form::VALID) {
         $operation = ':dateInputValid';
     }
     return parent::addRule($operation, $message, $arg);
 }
开发者ID:BroukPytlik,项目名称:agility,代码行数:20,代码来源:DateInput.php

示例12: addRule

 /**
  * @param $validator
  * @param null $message
  * @param array|null $arg
  *
  * @return $this|BaseControl
  *
  * @throws DatePickerException
  */
 public function addRule($validator, $message = NULL, $arg = NULL)
 {
     // check for disabled dates
     if ($validator == self::DISABLED_DATES) {
         if (!is_array($arg)) {
             throw new DatePickerException('Rule argument is not valid! Array of \\DateTime objects is expected. ' . get_class($arg) . ' given.');
         }
         foreach ($arg as $date) {
             if ($date instanceof \DateTime) {
                 // add only instances of DateTime
                 $this->setDisabledDate($date);
             }
         }
         parent::addRule($validator, $message, $this->datesDisabled);
     } elseif ($validator == self::DISABLED_DAYS) {
         if (is_array($arg)) {
             // filter array values
             $arg = array_filter($arg, 'Vojtys\\Forms\\DatePicker\\DatePickerBase::isInRange');
             $this->setDaysOfWeekDisabled($arg);
             parent::addRule($validator, $message, $arg);
         } else {
             throw new DatePickerException('Rule argument is not valid! Array is expected ' . get_class($arg) . ' given.');
         }
     } elseif ($validator == self::DATE_TIME_MIN) {
         if ($arg instanceof \DateTime) {
             $this->setStartDate($arg);
             // set datepicker option
             parent::addRule($validator, $message, $arg);
         } else {
             throw new DatePickerException('Rule argument is not valid! \\DateTime object is expected. ' . get_class($arg) . ' given.');
         }
     } elseif ($validator == self::DATE_TIME_MAX) {
         if ($arg instanceof \DateTime) {
             $this->setEndDate($arg);
             // set datepicker option
             parent::addRule($validator, $message, $arg);
         } else {
             throw new DatePickerException('Rule argument is not valid! \\DateTime object is expected. ' . get_class($arg) . ' given.');
         }
     } else {
         parent::addRule($validator, $message, $arg);
     }
     return $this;
 }
开发者ID:vojtys,项目名称:bootstrap-datepicker,代码行数:53,代码来源:DatePickerBase.php


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