mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
adjusted apidoc for MaskedInput widget
This commit is contained in:
@ -22,21 +22,24 @@ use yii\web\View;
|
|||||||
* To use MaskedInput, you must set the [[mask]] property. The following example
|
* To use MaskedInput, you must set the [[mask]] property. The following example
|
||||||
* shows how to use MaskedInput to collect phone numbers:
|
* shows how to use MaskedInput to collect phone numbers:
|
||||||
*
|
*
|
||||||
* ~~~
|
* ```php
|
||||||
* echo MaskedInput::widget([
|
* echo MaskedInput::widget([
|
||||||
* 'name' => 'phone',
|
* 'name' => 'phone',
|
||||||
* 'mask' => '999-999-9999',
|
* 'mask' => '999-999-9999',
|
||||||
* ]);
|
* ]);
|
||||||
* ~~~
|
* ```
|
||||||
*
|
*
|
||||||
* The masked text field is implemented based on the
|
* The masked text field is implemented based on the
|
||||||
* [jQuery input mask plugin](https://github.com/RobinHerbots/jquery.inputmask).
|
* [jQuery input masked plugin](https://github.com/RobinHerbots/jquery.inputmask).
|
||||||
*
|
*
|
||||||
* @author Kartik Visweswaran <kartikv2@gmail.com>
|
* @author Kartik Visweswaran <kartikv2@gmail.com>
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class MaskedInput extends InputWidget
|
class MaskedInput extends InputWidget
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The name of the jQuery plugin to use for this widget.
|
||||||
|
*/
|
||||||
const PLUGIN_NAME = 'inputmask';
|
const PLUGIN_NAME = 'inputmask';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,36 +50,34 @@ class MaskedInput extends InputWidget
|
|||||||
* - `9`: represents a numeric character (0-9)
|
* - `9`: represents a numeric character (0-9)
|
||||||
* - `*`: represents an alphanumeric character (A-Z, a-z, 0-9)
|
* - `*`: represents an alphanumeric character (A-Z, a-z, 0-9)
|
||||||
* - `[` and `]`: anything entered between the square brackets is considered optional user input. This is
|
* - `[` and `]`: anything entered between the square brackets is considered optional user input. This is
|
||||||
* based on the `optionalmarker` setting in `clientOptions`.
|
* based on the `optionalmarker` setting in [[clientOptions]].
|
||||||
*
|
*
|
||||||
* Additional definitions can be set through definitions property.
|
* Additional definitions can be set through the [[definitions]] property.
|
||||||
*/
|
*/
|
||||||
public $mask;
|
public $mask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array custom mask definitions to use. Should be configured as `$maskSymbol => $settings`, where:
|
* @var array custom mask definitions to use. Should be configured as `maskSymbol => settings`, where
|
||||||
* - `maskSymbol`: string, a character to identify your mask definition
|
*
|
||||||
* - `settings`: array, consisiting of the following entries:
|
* - `maskSymbol` is a string, containing a character to identify your mask definition and
|
||||||
* - `validator`: string, a JS regular expression or a JS function.
|
* - `settings` is an array, consisiting of the following entries:
|
||||||
|
* - `validator`: string, a JS regular expression or a JS function.
|
||||||
* - `cardinality`: int, specifies how many characters are represented and validated for the definition.
|
* - `cardinality`: int, specifies how many characters are represented and validated for the definition.
|
||||||
* - `prevalidator`: array, validate the characters before the definition cardinality is reached.
|
* - `prevalidator`: array, validate the characters before the definition cardinality is reached.
|
||||||
* - `definitionSymbol`: string, allows shifting values from other definitions, with this `definitionSymbol`.
|
* - `definitionSymbol`: string, allows shifting values from other definitions, with this `definitionSymbol`.
|
||||||
*/
|
*/
|
||||||
public $definitions;
|
public $definitions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array custom aliases to use. Should be configured as `$maskAlias` => $settings`, where:
|
* @var array custom aliases to use. Should be configured as `maskAlias => settings`, where
|
||||||
* - `maskAlias`: string, a text to identify your mask alias definition (e.g. 'phone')
|
*
|
||||||
* - `settings`: array settings for the mask symbol, exactly similar to parameters as passed in `clientOptions`
|
* - `maskAlias` is a string containing a text to identify your mask alias definition (e.g. 'phone') and
|
||||||
|
* - `settings` is an array containing settings for the mask symbol, exactly similar to parameters as passed in [[clientOptions]].
|
||||||
*/
|
*/
|
||||||
public $aliases;
|
public $aliases;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array the JQuery plugin options for the input mask plugin.
|
* @var array the JQuery plugin options for the input mask plugin.
|
||||||
* @see https://github.com/RobinHerbots/jquery.inputmask
|
* @see https://github.com/RobinHerbots/jquery.inputmask
|
||||||
*/
|
*/
|
||||||
public $clientOptions = [];
|
public $clientOptions = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array the HTML attributes for the input tag.
|
* @var array the HTML attributes for the input tag.
|
||||||
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
|
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
|
||||||
@ -88,6 +89,7 @@ class MaskedInput extends InputWidget
|
|||||||
*/
|
*/
|
||||||
protected $_hashVar;
|
protected $_hashVar;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the widget.
|
* Initializes the widget.
|
||||||
*
|
*
|
||||||
@ -102,10 +104,7 @@ class MaskedInput extends InputWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @inheritdoc
|
||||||
* Runs the widget.
|
|
||||||
*
|
|
||||||
* @return string|void
|
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
@ -121,6 +120,7 @@ class MaskedInput extends InputWidget
|
|||||||
* Generates a hashed variable to store the plugin `clientOptions`. Helps in reusing the variable for similar
|
* Generates a hashed variable to store the plugin `clientOptions`. Helps in reusing the variable for similar
|
||||||
* options passed for other widgets on the same page. The following special data attributes will also be
|
* options passed for other widgets on the same page. The following special data attributes will also be
|
||||||
* setup for the input widget, that can be accessed through javascript:
|
* setup for the input widget, that can be accessed through javascript:
|
||||||
|
*
|
||||||
* - 'data-plugin-options' will store the hashed variable storing the plugin options.
|
* - 'data-plugin-options' will store the hashed variable storing the plugin options.
|
||||||
* - 'data-plugin-name' the name of the plugin
|
* - 'data-plugin-name' the name of the plugin
|
||||||
*
|
*
|
||||||
|
@ -11,6 +11,7 @@ use yii\web\AssetBundle;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The asset bundle for the [[MaskedInput]] widget.
|
* The asset bundle for the [[MaskedInput]] widget.
|
||||||
|
*
|
||||||
* Includes client assets of [jQuery input mask plugin](https://github.com/RobinHerbots/jquery.inputmask).
|
* Includes client assets of [jQuery input mask plugin](https://github.com/RobinHerbots/jquery.inputmask).
|
||||||
*
|
*
|
||||||
* @author Kartik Visweswaran <kartikv2@gmail.com>
|
* @author Kartik Visweswaran <kartikv2@gmail.com>
|
||||||
@ -19,6 +20,10 @@ use yii\web\AssetBundle;
|
|||||||
class MaskedInputAsset extends AssetBundle
|
class MaskedInputAsset extends AssetBundle
|
||||||
{
|
{
|
||||||
public $sourcePath = '@yii/assets';
|
public $sourcePath = '@yii/assets';
|
||||||
public $js = ['jquery.inputmask.bundle.min.js'];
|
public $js = [
|
||||||
public $depends = ['yii\web\YiiAsset'];
|
'jquery.inputmask.bundle.min.js'
|
||||||
|
];
|
||||||
|
public $depends = [
|
||||||
|
'yii\web\YiiAsset'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user