本文整理汇总了PHP中yii\helpers\Html::escapeJsRegularExpression方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::escapeJsRegularExpression方法的具体用法?PHP Html::escapeJsRegularExpression怎么用?PHP Html::escapeJsRegularExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::escapeJsRegularExpression方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClientOptions
/**
* @inheritdoc
*/
public function getClientOptions($model, $attribute)
{
$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;
}
return $options;
}
示例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) . ');';
}
示例3: 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) . ');';
}
示例4: getClientOptions
/**
* @inheritdoc
*/
public function getClientOptions($model, $attribute)
{
$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;
}
return $options;
}
示例5: getClientOptions
/**
* @inheritdoc
*/
public function getClientOptions($model, $attribute)
{
$label = $model->getAttributeLabel($attribute);
$options = [];
if ($this->message !== null) {
$options['message'] = Yii::$app->getI18n()->format($this->message, ['attribute' => $label], Yii::$app->language);
}
$options['skipOnEmpty'] = $this->skipOnEmpty;
if (!$this->skipOnEmpty) {
$options['uploadRequired'] = Yii::$app->getI18n()->format($this->uploadRequired, ['attribute' => $label], Yii::$app->language);
}
if ($this->mimeTypes !== null) {
$mimeTypes = [];
foreach ($this->mimeTypes as $mimeType) {
$mimeTypes[] = new JsExpression(Html::escapeJsRegularExpression($this->buildMimeTypeRegexp($mimeType)));
}
$options['mimeTypes'] = $mimeTypes;
$options['wrongMimeType'] = Yii::$app->getI18n()->format($this->wrongMimeType, ['attribute' => $label, 'mimeTypes' => implode(', ', $this->mimeTypes)], Yii::$app->language);
}
if ($this->extensions !== null) {
$options['extensions'] = $this->extensions;
$options['wrongExtension'] = Yii::$app->getI18n()->format($this->wrongExtension, ['attribute' => $label, 'extensions' => implode(', ', $this->extensions)], Yii::$app->language);
}
if ($this->minSize !== null) {
$options['minSize'] = $this->minSize;
$options['tooSmall'] = Yii::$app->getI18n()->format($this->tooSmall, ['attribute' => $label, 'limit' => $this->minSize, 'formattedLimit' => Yii::$app->formatter->asShortSize($this->minSize)], Yii::$app->language);
}
if ($this->maxSize !== null) {
$options['maxSize'] = $this->maxSize;
$options['tooBig'] = Yii::$app->getI18n()->format($this->tooBig, ['attribute' => $label, 'limit' => $this->getSizeLimit(), 'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit())], Yii::$app->language);
}
if ($this->maxFiles !== null) {
$options['maxFiles'] = $this->maxFiles;
$options['tooMany'] = Yii::$app->getI18n()->format($this->tooMany, ['attribute' => $label, 'limit' => $this->maxFiles], Yii::$app->language);
}
return $options;
}
示例6: clientValidateAttribute
/**
* @inheritdoc
*/
public function clientValidateAttribute($model, $attribute, $view)
{
$pattern = Html::escapeJsRegularExpression($this->pattern);
$options = ['pattern' => new JsExpression($pattern), 'not' => $this->not];
if ($this->skipOnEmpty) {
$options['skipOnEmpty'] = 1;
}
$pattern = Html::escapeJsRegularExpression($this->patternOnPass);
$optionsPass = ['pattern' => new JsExpression($pattern), 'not' => $this->notOnPass, 'message' => Yii::$app->getI18n()->format($this->messageOnPass, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language)];
if ($this->skipOnEmpty) {
$optionsPass['skipOnEmpty'] = 1;
}
if ($this->patternOnFail === false) {
$optionsFail = false;
} else {
$pattern = Html::escapeJsRegularExpression($this->patternOnFail);
$optionsFail = ['pattern' => new JsExpression($pattern), 'not' => $this->notOnFail, 'message' => Yii::$app->getI18n()->format($this->messageOnFail, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language)];
if ($this->skipOnEmpty) {
$optionsFail['skipOnEmpty'] = 1;
}
}
ValidationAsset::register($view);
return 'localAppValidation.conditionalRegExp(value, messages, ' . Json::htmlEncode($options) . ', ' . Json::htmlEncode($optionsPass) . ', ' . Json::htmlEncode($optionsFail) . ');';
}