widgets\ActiveField widget()

widget() public method

Renders a widget as the input of the field.

Note that the widget must have both model and attribute properties. They will be initialized with $model and $attribute of this field, respectively.

If you want to use a widget that does not have model and attribute properties, please use render() instead.

For example to use the yii\widgets\MaskedInput widget to get some date input, you can use the following code, assuming that $form is your yii\widgets\ActiveForm instance:

$form->field($model, 'date')->widget(\yii\widgets\MaskedInput::className(), [
    'mask' => '99/99/9999',
]);

If you set a custom id for the input element, you may need to adjust the $selectors accordingly.

public $this widget ( $class, $config = [] )
$class string

The widget class name.

$config array

Name-value pairs that will be used to initialize the widget.

return $this

The field object itself.

doc_Yii
2016-10-30 17:17:55
Comments
Leave a Comment

Please login to continue.