Home > Article > Backend Development > Smarty package YII2 Form API - Switch Switch
Form element name: switch
Basic call format:
{input type='switch' model=$model field='is_parent' value='1' uncheck='0' items=[0='否, '1'=>'是']}
API description:
1. The "type" of the switch must be switch
2.value specifies the value when checked, the default is 1; uncheck specifies The value when unchecking is specified, the default is 0.
3.items specifies the text on the switch, the type is an array, the key corresponds to the attribute value of value and uncheck, and the value corresponds to the displayed text. The default properties of
4.items are:
['0'=>'否', '1'=>'是']
Rendering:
The above introduces the Smarty package YII2 Form API - Switch, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.