Example #1
0
 /**
  * If `maxlength` option is set true and the model attribute is validated by a string validator,
  * the `maxlength` option will take the value of [[\Leaps\Validator\StringValidator::max]].
  * @param Model $model the model object
  * @param string $attribute the attribute name or expression.
  * @param array $options the tag options in terms of name-value pairs.
  */
 private static function normalizeMaxLength($model, $attribute, &$options)
 {
     if (isset($options['maxlength']) && $options['maxlength'] === true) {
         unset($options['maxlength']);
         $attrName = static::getAttributeName($attribute);
         foreach ($model->getActiveValidators($attrName) as $validator) {
             if ($validator instanceof StringValidator && $validator->max !== null) {
                 $options['maxlength'] = $validator->max;
                 break;
             }
         }
     }
 }