Home  >  Article  >  Backend Development  >  Smarty package YII2 Form API - Switch Switch

Smarty package YII2 Form API - Switch Switch

WBOY
WBOYOriginal
2016-07-29 09:06:131258browse

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:


Smarty package YII2 Form API - Switch SwitchSmarty package YII2 Form API - Switch Switch

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn