public function clientValidateAttribute($model, $attribute, $view)
 {
     $js = parent::clientValidateAttribute($model, $attribute, $view);
     if (!$this->enableIdn) {
         return $js;
     }
     PunycodeAsset::register($view);
     return "value = punycode.toASCII(value); {$js}";
 }
Exemple #2
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' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$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 'yii.validation.url(value, messages, ' . Json::encode($options) . ');';
 }
Exemple #3
0
 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = ['pattern' => new JsExpression($this->pattern), 'fullPattern' => new JsExpression($this->fullPattern), 'allowName' => $this->allowName, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language), 'enableIDN' => (bool) $this->enableIDN];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     if ($this->enableIDN) {
         PunycodeAsset::register($view);
     }
     return 'yii.validation.email(value, messages, ' . Json::htmlEncode($options) . ');';
 }
Exemple #4
0
 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     ValidationAsset::register($view);
     if ($this->enableIDN) {
         PunycodeAsset::register($view);
     }
     $options = $this->getClientOptions($model, $attribute);
     return 'yii.validation.url(value, messages, ' . Json::htmlEncode($options) . ');';
 }