Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
c26c9396
Commit
c26c9396
authored
Dec 28, 2011
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
702476d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
InlineValidator.php
framework/validators/InlineValidator.php
+41
-0
No files found.
framework/validators/InlineValidator.php
View file @
c26c9396
...
@@ -34,6 +34,20 @@ class InlineValidator extends Validator
...
@@ -34,6 +34,20 @@ class InlineValidator extends Validator
* @var array additional parameters that are passed to the validation method
* @var array additional parameters that are passed to the validation method
*/
*/
public
$params
;
public
$params
;
/**
* @var string the name of the method that returns the client validation code (see [[clientValidateAttribute()]]
* for details on how to return client validation code). The signature of the method should be like the following:
*
* ~~~
* function foo($attribute)
* {
* return "javascript";
* }
* ~~~
*
* where `$attribute` refers to the attribute name to be validated.
*/
public
$clientValidate
;
/**
/**
* Validates the attribute of the object.
* Validates the attribute of the object.
...
@@ -45,4 +59,31 @@ class InlineValidator extends Validator
...
@@ -45,4 +59,31 @@ class InlineValidator extends Validator
$method
=
$this
->
method
;
$method
=
$this
->
method
;
$object
->
$method
(
$attribute
,
$this
->
params
);
$object
->
$method
(
$attribute
,
$this
->
params
);
}
}
/**
* Returns the JavaScript needed for performing client-side validation.
*
* You may override this method to return the JavaScript validation code if
* the validator can support client-side validation.
*
* The following JavaScript variables are predefined and can be used in the validation code:
*
* - `attribute`: the name of the attribute being validated.
* - `value`: the value being validated.
* - `messages`: an array used to hold the validation error messages for the attribute.
*
* @param \yii\base\Model $object the data object being validated
* @param string $attribute the name of the attribute to be validated.
* @return string the client-side validation script. Null if the validator does not support
* client-side validation.
* @see enableClientValidation
* @see \yii\web\ActiveForm::enableClientValidation
*/
public
function
clientValidateAttribute
(
$object
,
$attribute
)
{
if
(
$this
->
clientValidate
!==
null
)
{
$method
=
$this
->
clientValidate
;
return
$object
->
$method
(
$attribute
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment