PHP Class macgyer\yii2materializecss\widgets\form\SwitchButton

Author: Christoph Erdmann ([email protected])
Inheritance: extends macgyer\yii2materializecss\lib\BaseInputWidget
Exibir arquivo Open project: macgyer/yii2-materializecss

Public Properties

Property Type Description
$attribute the model attribute that this widget is associated with.
$checked the control for setting the "checked" attribute in the input tag.
$encodeOffText whether the off text should be HTML-encoded.
$encodeOnText whether the on text should be HTML-encoded.
$inputOptions the HTML attributes for the underlying input tag.
$model the data model that this widget is associated with.
$name the input name. This must be set if [[model]] and [[attribute]] are not set.
$offIcon the options for the optional off icon. To specify an icon you can use the following parameters: php [ 'name' => 'name of the icon', // required 'position' => 'position of the icon', // optional, 'left' or 'right', defaults to 'left' 'options' => 'the HTML attributes for the img', // optional ]
$offText the text displaying the unchecked status. This can be used in conjunction with the [[offIcon]].
$onIcon the options for the optional on icon. To specify an icon you can use the following parameters: php [ 'name' => 'name of the icon', // required 'position' => 'position of the icon', // optional, 'left' or 'right', defaults to 'left' 'options' => 'the HTML attributes for the img', // optional ]
$onText the text displaying the checked status. This can be used in conjunction with the [[onIcon]].
$options the HTML attributes for the widget container tag. The following special options are recognized: - tag: string, defaults to "div", the name of the container tag.
$uncheck the value associated with the uncheck state of the radio button. If not set, it will take the default value '0'. This method will render a hidden input so that if the radio button is not checked and is submitted, the value of this attribute will still be submitted to the server via the hidden input. If you do not want any hidden input, you should explicitly set this option as null.
$value the input value. If not set, it will take the default value "1".

Public Methods

Method Description
init ( ) Initialize the widget.
run ( ) : string Executes the widget.

Protected Methods

Method Description
renderIcon ( string $state ) : string Renders an icon.
renderLabel ( string $state ) : string Renders the HTML markup for the on/off label.
renderSwitch ( ) : string Render the switch button checkbox.

Method Details

init() public method

Initialize the widget.
public init ( )

renderIcon() protected method

Renders an icon.
See also: Icon::run
protected renderIcon ( string $state ) : string
$state string the name of the icon property.
return string the rendered icon

renderLabel() protected method

This method also renders the corresponding icons, if set.
protected renderLabel ( string $state ) : string
$state string the state to used. Use "off" or "on".
return string the rendered label.

renderSwitch() protected method

Render the switch button checkbox.
protected renderSwitch ( ) : string
return string

run() public method

Executes the widget.
public run ( ) : string
return string the result of widget execution to be outputted.

Property Details

$attribute public_oe property

the model attribute that this widget is associated with.
public $attribute

$checked public_oe property

the control for setting the "checked" attribute in the input tag.
public $checked

$encodeOffText public_oe property

whether the off text should be HTML-encoded.
public $encodeOffText

$encodeOnText public_oe property

whether the on text should be HTML-encoded.
public $encodeOnText

$inputOptions public_oe property

the HTML attributes for the underlying input tag.
See also: [yii\helpers\BaseHtml::renderTagAttributes()](http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#renderTagAttributes()-detail) for details on how attributes are being rendered.
public $inputOptions

$model public_oe property

the data model that this widget is associated with.
public $model

$name public_oe property

the input name. This must be set if [[model]] and [[attribute]] are not set.
public $name

$offIcon public_oe property

the options for the optional off icon. To specify an icon you can use the following parameters: php [ 'name' => 'name of the icon', // required 'position' => 'position of the icon', // optional, 'left' or 'right', defaults to 'left' 'options' => 'the HTML attributes for the img', // optional ]
public $offIcon

$offText public_oe property

the text displaying the unchecked status. This can be used in conjunction with the [[offIcon]].
public $offText

$onIcon public_oe property

the options for the optional on icon. To specify an icon you can use the following parameters: php [ 'name' => 'name of the icon', // required 'position' => 'position of the icon', // optional, 'left' or 'right', defaults to 'left' 'options' => 'the HTML attributes for the img', // optional ]
public $onIcon

$onText public_oe property

the text displaying the checked status. This can be used in conjunction with the [[onIcon]].
public $onText

$options public_oe property

the HTML attributes for the widget container tag. The following special options are recognized: - tag: string, defaults to "div", the name of the container tag.
See also: [yii\helpers\BaseHtml::renderTagAttributes()](http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#renderTagAttributes()-detail) for details on how attributes are being rendered.
public $options

$uncheck public_oe property

the value associated with the uncheck state of the radio button. If not set, it will take the default value '0'. This method will render a hidden input so that if the radio button is not checked and is submitted, the value of this attribute will still be submitted to the server via the hidden input. If you do not want any hidden input, you should explicitly set this option as null.
public $uncheck

$value public_oe property

the input value. If not set, it will take the default value "1".
public $value