mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 06:37:55 +08:00 
			
		
		
		
	Fixes #6992.
This commit is contained in:
		@ -312,7 +312,7 @@ the method/function is:
 | 
				
			|||||||
```php
 | 
					```php
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @param string $attribute the attribute currently being validated
 | 
					 * @param string $attribute the attribute currently being validated
 | 
				
			||||||
 * @param array $params the additional name-value pairs given in the rule
 | 
					 * @param mixed $params the value of the "params" given in the rule
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
function ($attribute, $params)
 | 
					function ($attribute, $params)
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
				
			|||||||
@ -26,7 +26,9 @@ class InlineValidator extends Validator
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @var string|\Closure an anonymous function or the name of a model class method that will be
 | 
					     * @var string|\Closure an anonymous function or the name of a model class method that will be
 | 
				
			||||||
     * called to perform the actual validation. The signature of the method should be like the following:
 | 
					     * called to perform the actual validation. The signature of the method should be like the following,
 | 
				
			||||||
 | 
					     * where `$attribute` is the name of the attribute to be validated, and `$params` contains the value
 | 
				
			||||||
 | 
					     * of [[params]] that you specify when declaring the inline validation rule:
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * ~~~
 | 
					     * ~~~
 | 
				
			||||||
     * function foo($attribute, $params)
 | 
					     * function foo($attribute, $params)
 | 
				
			||||||
@ -34,7 +36,7 @@ class InlineValidator extends Validator
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public $method;
 | 
					    public $method;
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @var array additional parameters that are passed to the validation method
 | 
					     * @var mixed additional parameters that are passed to the validation method
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public $params;
 | 
					    public $params;
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -57,9 +57,10 @@ class ValidatorTest extends TestCase
 | 
				
			|||||||
        $this->assertInstanceOf(BooleanValidator::className(), $val);
 | 
					        $this->assertInstanceOf(BooleanValidator::className(), $val);
 | 
				
			||||||
        $this->assertSame(['a', 'b'], $val->on);
 | 
					        $this->assertSame(['a', 'b'], $val->on);
 | 
				
			||||||
        $this->assertSame(['c', 'd', 'e'], $val->except);
 | 
					        $this->assertSame(['c', 'd', 'e'], $val->except);
 | 
				
			||||||
        $val = TestValidator::createValidator('inlineVal', $model, ['val_attr_a']);
 | 
					        $val = TestValidator::createValidator('inlineVal', $model, ['val_attr_a'], ['params' => ['foo' => 'bar']]);
 | 
				
			||||||
        $this->assertInstanceOf(InlineValidator::className(), $val);
 | 
					        $this->assertInstanceOf(InlineValidator::className(), $val);
 | 
				
			||||||
        $this->assertSame('inlineVal', $val->method);
 | 
					        $this->assertSame('inlineVal', $val->method);
 | 
				
			||||||
 | 
					        $this->assertSame(['foo' => 'bar'], $val->params);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function testValidate()
 | 
					    public function testValidate()
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user