當前位置: 首頁>>代碼示例>>PHP>>正文


PHP validators\ValidationAsset類代碼示例

本文整理匯總了PHP中yii\validators\ValidationAsset的典型用法代碼示例。如果您正苦於以下問題:PHP ValidationAsset類的具體用法?PHP ValidationAsset怎麽用?PHP ValidationAsset使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ValidationAsset類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     if ($this->filter !== 'trim') {
         return null;
     }
     ValidationAsset::register($view);
     $options = $this->getClientOptions($model, $attribute);
     return 'value = yii.validation.trim($form, attribute, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }
開發者ID:kilyanov,項目名稱:yii2,代碼行數:12,代碼來源:FilterValidator.php

示例2: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $pattern = Html::escapeJsRegularExpression($this->pattern);
     $options = ['pattern' => new JsExpression($pattern), 'not' => $this->not, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.regularExpression(value, messages, ' . Json::htmlEncode($options) . ');';
 }
開發者ID:Jaaviieer,項目名稱:PrograWeb,代碼行數:13,代碼來源:RegularExpressionValidator.php

示例3: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $this->ensureEnum($model, $attribute);
     $options = ['range' => array_map('strval', array_keys($this->enum)), 'not' => false, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.range(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }
開發者ID:faryshta,項目名稱:yii2-enum,代碼行數:13,代碼來源:EnumValidator.php

示例4: clientValidateAttribute

 public function clientValidateAttribute($object, $attribute, $view)
 {
     $captcha = $this->createCaptchaAction();
     $code = $captcha->getVerifyCode(false);
     $hash = $captcha->generateValidationHash($this->caseSensitive ? $code : mb_strtolower($code));
     $options = ['hash' => $hash, 'hashKey' => 'yiiCaptcha/' . $this->captchaAction, 'caseSensitive' => $this->caseSensitive, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $object->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.captcha(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }
開發者ID:tsyrya,項目名稱:mybriop,代碼行數:12,代碼來源:CaptchaValidator.php

示例5: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = ['trueValue' => $this->trueValue, 'falseValue' => $this->falseValue, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute), 'true' => $this->trueValue === true ? 'true' : $this->trueValue, 'false' => $this->falseValue === false ? 'false' : $this->falseValue], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     if ($this->strict) {
         $options['strict'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.boolean(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }
開發者ID:sadiqhirani,項目名稱:yii2,代碼行數:15,代碼來源:BooleanValidator.php

示例6: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($object, $attribute, $view)
 {
     $options = ['trueValue' => $this->trueValue, 'falseValue' => $this->falseValue, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $object->getAttributeLabel($attribute), 'true' => $this->trueValue, 'false' => $this->falseValue], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     if ($this->strict) {
         $options['strict'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.boolean(value, messages, ' . json_encode($options) . ');';
 }
開發者ID:dw250100785,項目名稱:lulucms,代碼行數:15,代碼來源:BooleanValidator.php

示例7: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     if ($this->filter !== 'trim') {
         return null;
     }
     $options = [];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.trim($form, attribute, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }
開發者ID:hucongyang,項目名稱:lulucms2,代碼行數:15,代碼來源:FilterValidator.php

示例8: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($object, $attribute, $view)
 {
     $range = [];
     foreach ($this->range as $value) {
         $range[] = (string) $value;
     }
     $options = ['range' => $range, 'not' => $this->not, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $object->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.range(value, messages, ' . json_encode($options) . ');';
 }
開發者ID:yuexiaoyun,項目名稱:lulucms,代碼行數:16,代碼來源:RangeValidator.php

示例9: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = ['operator' => $this->operator, 'type' => $this->type];
     if ($this->compareValue !== null) {
         $options['compareValue'] = $this->compareValue;
         $compareValue = $this->compareValue;
     } else {
         $compareAttribute = $this->compareAttribute === null ? $attribute . '_repeat' : $this->compareAttribute;
         $compareValue = $model->getAttributeLabel($compareAttribute);
         $options['compareAttribute'] = Html::getInputId($model, $compareAttribute);
     }
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     $options['message'] = Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute), 'compareAttribute' => $compareValue, 'compareValue' => $compareValue], Yii::$app->language);
     ValidationAsset::register($view);
     return 'yii.validation.compare(attribute, value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }
開發者ID:kalibao,項目名稱:magesko,代碼行數:21,代碼來源:CompareValidator.php

示例10: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = [];
     if ($this->requiredValue !== null) {
         $options['message'] = Yii::$app->getI18n()->format($this->message, ['requiredValue' => $this->requiredValue], Yii::$app->language);
         $options['requiredValue'] = $this->requiredValue;
     } else {
         $options['message'] = $this->message;
     }
     if ($this->strict) {
         $options['strict'] = 1;
     }
     $options['message'] = Yii::$app->getI18n()->format($options['message'], ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language);
     ValidationAsset::register($view);
     $id = Html::getInputId($model, $attribute);
     // TODO require validation
     return '
     yii.validation.required(UE.getEditor("' . $id . '").getContent(), messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }
開發者ID:gerpayt,項目名稱:yii2-ueditor,代碼行數:22,代碼來源:UEditorValidator.php

示例11: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($object, $attribute, $view)
 {
     $pattern = $this->pattern;
     //$pattern = preg_replace('/\\\\x\{?([0-9a-fA-F]+)\}?/', '\u$1', $pattern);
     $deliminator = substr($pattern, 0, 1);
     $pos = strrpos($pattern, $deliminator, 1);
     $flag = substr($pattern, $pos + 1);
     if ($deliminator !== '/') {
         $pattern = '/' . str_replace('/', '\\/', substr($pattern, 1, $pos - 1)) . '/';
     } else {
         $pattern = substr($pattern, 0, $pos + 1);
     }
     if (!empty($flag)) {
         $pattern .= preg_replace('/[^igm]/', '', $flag);
     }
     $options = ['pattern' => new JsExpression($pattern), 'not' => $this->not, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $object->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.regularExpression(value, messages, ' . Json::encode($options) . ');';
 }
開發者ID:rajanishtimes,項目名稱:basicyii,代碼行數:25,代碼來源:AliasnameValidator.php

示例12: clientValidateAttribute

    public function clientValidateAttribute($model, $attribute, $view)
    {
        $className = explode('\\', $model->className());
        $className = strtolower(end($className));
        $formName = strtolower($model->formName());
        $label = $model->getAttributeLabel($attribute);
        $options = ['message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $label], Yii::$app->language)];
        $formName = strtolower($model->formName());
        $options = Json::htmlEncode($options);
        ValidationAsset::register($view);
        $view->registerJs(<<<JS
(function(){\t\t\t\t
var telInput = \$("#{$formName}-{$attribute}");
if (!telInput.intlTelInput('isValidNumber')) {
\tmessages.push({$options}.message);
}
\t\tvar intlNumber = telInput.intlTelInput("getNumber");
\t\ttelInput.value = intlNumber;
\t\t
\t\tdocument.getElementById("{$className}-{$attribute}").value = intlNumber;
 \t\tdocument.getElementById("{$className}-{$attribute}").disabled = false;
\t\t
\t\t//var countryData = \$.fn.intlTelInput.getCountryData();
\t\t//console.log(countryData);
})();
JS
, \yii\web\View::POS_LOAD);
        // 		$view->registerJs(<<<JS
        // (function(){
        //     var telInput = $('#$formName-$attribute');
        // 	if (!telInput.intlTelInput('isValidNumber')) {
        // 	messages.push($options.message);
        // 		   }
        // })();
        // JS
        // 		, \yii\web\View::POS_LOAD);
    }
開發者ID:indicalabs,項目名稱:yii2-phone,代碼行數:37,代碼來源:IntlTelNumberValidator.php

示例13: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     ValidationAsset::register($view);
     $options = $this->getClientOptions($model, $attribute);
     return 'yii.validation.image(attribute, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ', deferred);';
 }
開發者ID:Jaaviieer,項目名稱:PrograWeb,代碼行數:9,代碼來源:ImageValidator.php

示例14: clientValidateAttribute

 /**
  * @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) . ');';
 }
開發者ID:arogachev,項目名稱:yii2,代碼行數:15,代碼來源:EmailValidator.php

示例15: clientValidateAttribute

 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $messages = ['ipv6NotAllowed' => $this->ipv6NotAllowed, 'ipv4NotAllowed' => $this->ipv4NotAllowed, 'message' => $this->message, 'noSubnet' => $this->noSubnet, 'hasSubnet' => $this->hasSubnet];
     foreach ($messages as &$message) {
         $message = Yii::$app->getI18n()->format($message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language);
     }
     $options = ['ipv4Pattern' => new JsExpression(Html::escapeJsRegularExpression($this->ipv4Pattern)), 'ipv6Pattern' => new JsExpression(Html::escapeJsRegularExpression($this->ipv6Pattern)), 'messages' => $messages, 'ipv4' => (bool) $this->ipv4, 'ipv6' => (bool) $this->ipv6, 'ipParsePattern' => new JsExpression(Html::escapeJsRegularExpression($this->getIpParsePattern())), 'negation' => $this->negation, 'subnet' => $this->subnet];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.ip(value, messages, ' . Json::htmlEncode($options) . ');';
 }
開發者ID:yiisoft,項目名稱:yii2,代碼行數:16,代碼來源:IpValidator.php


注:本文中的yii\validators\ValidationAsset類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。