当前位置: 首页>>代码示例>>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;未经允许,请勿转载。