mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Make validator getClientOptions public
This allows implementing custom client-side validation without extending every validator. Fixes #11163 close #13145
This commit is contained in:
committed by
Carsten Brandt
parent
0e5efb91eb
commit
f5beaf3edf
@ -79,7 +79,7 @@ class BooleanValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$options = [
|
||||
'trueValue' => $this->trueValue,
|
||||
|
||||
@ -234,7 +234,7 @@ class CompareValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$options = [
|
||||
'operator' => $this->operator,
|
||||
|
||||
@ -121,7 +121,7 @@ class EmailValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$options = [
|
||||
'pattern' => new JsExpression($this->pattern),
|
||||
|
||||
@ -386,7 +386,7 @@ class FileValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$label = $model->getAttributeLabel($attribute);
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ class FilterValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$options = [];
|
||||
if ($this->skipOnEmpty) {
|
||||
|
||||
@ -172,7 +172,7 @@ class ImageValidator extends FileValidator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$options = parent::getClientOptions($model, $attribute);
|
||||
|
||||
|
||||
@ -597,7 +597,7 @@ class IpValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$messages = [
|
||||
'ipv6NotAllowed' => $this->ipv6NotAllowed,
|
||||
|
||||
@ -130,7 +130,7 @@ class NumberValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$label = $model->getAttributeLabel($attribute);
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ class RangeValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$range = [];
|
||||
foreach ($this->range as $value) {
|
||||
|
||||
@ -74,7 +74,7 @@ class RegularExpressionValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$pattern = Html::escapeJsRegularExpression($this->pattern);
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ class RequiredValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$options = [];
|
||||
if ($this->requiredValue !== null) {
|
||||
|
||||
@ -159,7 +159,7 @@ class StringValidator extends Validator
|
||||
return 'yii.validation.string(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
|
||||
}
|
||||
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
$label = $model->getAttributeLabel($attribute);
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ class UrlValidator extends Validator
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
if (strpos($this->pattern, '{schemes}') !== false) {
|
||||
$pattern = str_replace('{schemes}', '(' . implode('|', $this->validSchemes) . ')', $this->pattern);
|
||||
|
||||
@ -372,7 +372,7 @@ class Validator extends Component
|
||||
* @return array the client-side validation options
|
||||
* @since 2.0.11
|
||||
*/
|
||||
protected function getClientOptions($model, $attribute)
|
||||
public function getClientOptions($model, $attribute)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user