Interface yii\validators\client\ClientValidatorScriptInterface
| Available since version | 22.0 |
|---|---|
| Source Code | https://github.com/yiisoft/yii2/blob/master/framework/validators/client/ClientValidatorScriptInterface.php |
Defines the contract for client-side validator script generation.
Classes implementing this interface provide methods for retrieving client-side validation options and registering the corresponding JavaScript code for a given validator, model, and attribute.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getClientOptions() | Returns client-side validation options for the specified validator, model, and attribute. | yii\ |
| register() | Registers the client-side validation script for the specified validator, model, and attribute in the view. | yii\ |
Method Details
Returns client-side validation options for the specified validator, model, and attribute.
| public abstract array | ||
| $validator | \ |
The validator instance. |
| $model | yii\ |
The data model being validated. |
| $attribute | string |
The attribute name being validated. |
| return | array |
Client-side validation options. |
|---|---|---|
public function getClientOptions(Validator $validator, Model $model, string $attribute): array;
Registers the client-side validation script for the specified validator, model, and attribute in the view.
| public abstract string|null register ( \ | ||
| $validator | \ |
The validator instance. |
| $model | yii\ |
The data model being validated. |
| $attribute | string |
The attribute name being validated. |
| $view | yii\ |
The view instance where the script will be registered. |
| return | string|null |
The client-side validation script, or |
|---|---|---|
public function register(Validator $validator, Model $model, string $attribute, View $view): string|null;
User Contributed Notes
Leave a comment
Join the conversation to share a note.