Пример #1
0
 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     if (strpos($this->pattern, '{schemes}') !== false) {
         $pattern = str_replace('{schemes}', '(' . implode('|', $this->validSchemes) . ')', $this->pattern);
     } else {
         $pattern = $this->pattern;
     }
     $options = ['pattern' => new JsExpression($pattern), 'message' => Leaps::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Leaps::$app->language), 'enableIDN' => (bool) $this->enableIDN];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     if ($this->defaultScheme !== null) {
         $options['defaultScheme'] = $this->defaultScheme;
     }
     ValidationAsset::register($view);
     if ($this->enableIDN) {
         PunycodeAsset::register($view);
     }
     return 'leaps.validation.url(value, messages, ' . Json::htmlEncode($options) . ');';
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = ['pattern' => new JsExpression($this->pattern), 'fullPattern' => new JsExpression($this->fullPattern), 'allowName' => $this->allowName, 'message' => Leaps::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Leaps::$app->language), 'enableIDN' => (bool) $this->enableIDN];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     if ($this->enableIDN) {
         PunycodeAsset::register($view);
     }
     return 'leaps.validation.email(value, messages, ' . Json::htmlEncode($options) . ');';
 }