文本框<span class="hljs-selector-pseudo">:textInput()</span>;
密码框<span class="hljs-selector-pseudo">:passwordInput()</span>;
单选框<span class="hljs-selector-pseudo">:radio()</span>,<span class="hljs-selector-tag">radioList</span>();
复选框<span class="hljs-selector-pseudo">:checkbox()</span>,<span class="hljs-selector-tag">checkboxList</span>();
下拉框<span class="hljs-selector-pseudo">:dropDownList()</span>;
隐藏域<span class="hljs-selector-pseudo">:hiddenInput()</span>;
文本域<span class="hljs-selector-pseudo">:textarea(</span><span class="hljs-selector-attr">['rows'=>3]</span>);
文件上传<span class="hljs-selector-pseudo">:fileInput()</span>;
提交按钮<span class="hljs-selector-pseudo">:submitButton()</span>;
重置按钮<span class="hljs-selector-pseudo">:resetButtun()</span>;
<span class="php"><span class="hljs-meta"><?php</span> $form = ActiveForm::begin([<span class="hljs-string">'action'</span> => [<span class="hljs-string">'test/getpost'</span>],<span class="hljs-string">'method'</span>=><span class="hljs-string">'post'</span>,]); <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> $form->field($model, <span class="hljs-string">'username'</span>)->textInput([<span class="hljs-string">'maxlength'</span> => <span class="hljs-number">20</span>]) <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> $form->field($model, <span class="hljs-string">'password'</span>)->passwordInput([<span class="hljs-string">'maxlength'</span> => <span class="hljs-number">20</span>]) <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> $form->field($model, <span class="hljs-string">'sex'</span>)->radioList([<span class="hljs-string">'1'</span>=><span class="hljs-string">'男'</span>,<span class="hljs-string">'0'</span>=><span class="hljs-string">'女'</span>]) <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> $form->field($model, <span class="hljs-string">'edu'</span>)->dropDownList([<span class="hljs-string">'1'</span>=><span class="hljs-string">'大学'</span>,<span class="hljs-string">'2'</span>=><span class="hljs-string">'高中'</span>,<span class="hljs-string">'3'</span>=><span class="hljs-string">'初中'</span>], [<span class="hljs-string">'prompt'</span>=><span class="hljs-string">'请选择'</span>,<span class="hljs-string">'style'</span>=><span class="hljs-string">'width:120px'</span>]) <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> $form->field($model, <span class="hljs-string">'file'</span>)->fileInput() <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> $form->field($model, <span class="hljs-string">'hobby'</span>)->checkboxList([<span class="hljs-string">'0'</span>=><span class="hljs-string">'篮球'</span>,<span class="hljs-string">'1'</span>=><span class="hljs-string">'足球'</span>,<span class="hljs-string">'2'</span>=><span class="hljs-string">'羽毛球'</span>,<span class="hljs-string">'3'</span>=><span class="hljs-string">'乒乓球'</span>]) <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> $form->field($model, <span class="hljs-string">'info'</span>)->textarea([<span class="hljs-string">'rows'</span>=><span class="hljs-number">3</span>]) <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> $form->field($model, <span class="hljs-string">'userid'</span>)->hiddenInput([<span class="hljs-string">'value'</span>=><span class="hljs-number">3</span>]) <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> Html::submitButton(<span class="hljs-string">'提交'</span>, [<span class="hljs-string">'class'</span>=><span class="hljs-string">'btn btn-primary'</span>,<span class="hljs-string">'name'</span> =><span class="hljs-string">'submit-button'</span>]) <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?</span> <span class="hljs-keyword">echo</span> Html::resetButton(<span class="hljs-string">'重置'</span>, [<span class="hljs-string">'class'</span>=><span class="hljs-string">'btn btn-primary'</span>,<span class="hljs-string">'name'</span> =><span class="hljs-string">'submit-button'</span>]) <span class="hljs-meta">?></span></span>
<span class="php"><span class="hljs-meta"><?php</span> ActiveForm::end(); <span class="hljs-meta">?></span></span>
yii 表单小部件
最新推荐文章于 2020-03-15 11:32:22 发布