PHP Класс yii\widgets\MaskedInput

MaskedInput is similar to [[Html::textInput()]] except that an input mask will be used to force users to enter properly formatted data, such as phone numbers, social security numbers. To use MaskedInput, you must set the [[mask]] property. The following example shows how to use MaskedInput to collect phone numbers: ~~~ echo MaskedInput::widget([ 'name' => 'phone', 'mask' => '999-999-9999', ]); ~~~ The masked text field is implemented based on the jQuery masked input plugin.
С версии: 2.0
Автор: Qiang Xue ([email protected])
Наследование: extends InputWidget
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$aliases custom aliases to use. Should be configured as maskAlias => settings, where - 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]].
$clientOptions the JQuery plugin options for the input mask plugin.
$definitions custom mask definitions to use. Should be configured as maskSymbol => settings, where - maskSymbol is a string, containing a character to identify your mask definition and - settings is an array, consisting 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. - prevalidator: array, validate the characters before the definition cardinality is reached. - definitionSymbol: string, allows shifting values from other definitions, with this definitionSymbol.
$mask the input mask (e.g. '99/99/9999' for date input). The following characters can be used in the mask and are predefined: - a: represents an alpha character (A-Z, a-z) - 9: represents a numeric character (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 based on the optionalmarker setting in [[clientOptions]]. Additional definitions can be set through the [[definitions]] property.
$options the HTML attributes for the input tag.
$type the type of the input tag. Currently only 'text' and 'tel' are supported.

Защищенные свойства (Protected)

Свойство Тип Описание
$_hashVar the hashed variable to store the pluginOptions

Открытые методы

Метод Описание
init ( ) Initializes the widget.
registerClientScript ( ) Registers the needed client script and options.
run ( )

Защищенные методы

Метод Описание
hashPluginOptions ( View $view ) 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 attribute will also be added to the input field to allow accessing the client options via javascript:
initClientOptions ( ) Initializes client options

Описание методов

hashPluginOptions() защищенный Метод

- 'data-plugin-inputmask' will store the hashed variable storing the plugin options.
Автор: [Thiago Talma](https://github.com/thiagotalma)
protected hashPluginOptions ( View $view )
$view yii\web\View the view instance

init() публичный Метод

Initializes the widget.
public init ( )

initClientOptions() защищенный Метод

Initializes client options
protected initClientOptions ( )

registerClientScript() публичный Метод

Registers the needed client script and options.

run() публичный Метод

public run ( )

Описание свойств

$_hashVar защищенное свойство

the hashed variable to store the pluginOptions
protected $_hashVar

$aliases публичное свойство

custom aliases to use. Should be configured as maskAlias => settings, where - 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

$clientOptions публичное свойство

the JQuery plugin options for the input mask plugin.
См. также: https://github.com/RobinHerbots/jquery.inputmask
public $clientOptions

$definitions публичное свойство

custom mask definitions to use. Should be configured as maskSymbol => settings, where - maskSymbol is a string, containing a character to identify your mask definition and - settings is an array, consisting 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. - prevalidator: array, validate the characters before the definition cardinality is reached. - definitionSymbol: string, allows shifting values from other definitions, with this definitionSymbol.
public $definitions

$mask публичное свойство

the input mask (e.g. '99/99/9999' for date input). The following characters can be used in the mask and are predefined: - a: represents an alpha character (A-Z, a-z) - 9: represents a numeric character (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 based on the optionalmarker setting in [[clientOptions]]. Additional definitions can be set through the [[definitions]] property.
public $mask

$options публичное свойство

the HTML attributes for the input tag.
См. также: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $options

$type публичное свойство

the type of the input tag. Currently only 'text' and 'tel' are supported.
См. также: https://github.com/RobinHerbots/jquery.inputmask
С версии: 2.0.6
public $type