Make validator getClientOptions public

This allows implementing custom client-side validation
without extending every validator.

Fixes #11163
close #13145
This commit is contained in:
Nikola Kovacs
2016-12-06 11:21:20 +01:00
committed by Carsten Brandt
parent 0e5efb91eb
commit f5beaf3edf
18 changed files with 24 additions and 21 deletions

View File

@ -79,7 +79,7 @@ class BooleanValidator extends Validator
/**
* @inheritdoc
*/
protected function getClientOptions($model, $attribute)
public function getClientOptions($model, $attribute)
{
$options = [
'trueValue' => $this->trueValue,

View File

@ -234,7 +234,7 @@ class CompareValidator extends Validator
/**
* @inheritdoc
*/
protected function getClientOptions($model, $attribute)
public function getClientOptions($model, $attribute)
{
$options = [
'operator' => $this->operator,

View File

@ -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),

View File

@ -386,7 +386,7 @@ class FileValidator extends Validator
/**
* @inheritdoc
*/
protected function getClientOptions($model, $attribute)
public function getClientOptions($model, $attribute)
{
$label = $model->getAttributeLabel($attribute);

View File

@ -97,7 +97,7 @@ class FilterValidator extends Validator
/**
* @inheritdoc
*/
protected function getClientOptions($model, $attribute)
public function getClientOptions($model, $attribute)
{
$options = [];
if ($this->skipOnEmpty) {

View File

@ -172,7 +172,7 @@ class ImageValidator extends FileValidator
/**
* @inheritdoc
*/
protected function getClientOptions($model, $attribute)
public function getClientOptions($model, $attribute)
{
$options = parent::getClientOptions($model, $attribute);

View File

@ -597,7 +597,7 @@ class IpValidator extends Validator
/**
* @inheritdoc
*/
protected function getClientOptions($model, $attribute)
public function getClientOptions($model, $attribute)
{
$messages = [
'ipv6NotAllowed' => $this->ipv6NotAllowed,

View File

@ -130,7 +130,7 @@ class NumberValidator extends Validator
/**
* @inheritdoc
*/
protected function getClientOptions($model, $attribute)
public function getClientOptions($model, $attribute)
{
$label = $model->getAttributeLabel($attribute);

View File

@ -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) {

View File

@ -74,7 +74,7 @@ class RegularExpressionValidator extends Validator
/**
* @inheritdoc
*/
protected function getClientOptions($model, $attribute)
public function getClientOptions($model, $attribute)
{
$pattern = Html::escapeJsRegularExpression($this->pattern);

View File

@ -97,7 +97,7 @@ class RequiredValidator extends Validator
/**
* @inheritdoc
*/
protected function getClientOptions($model, $attribute)
public function getClientOptions($model, $attribute)
{
$options = [];
if ($this->requiredValue !== null) {

View File

@ -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);

View File

@ -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);

View File

@ -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 [];
}