This article mainly introduces the usage of Activeform form components in YII2.0, combining the specific types of Activeform form components in the instance form and related usage skills, for more information about how to use the Activeform component of YII2.0, see the following example. We will share this with you for your reference. The details are as follows:
Activeform
Text Box: textInput ();
Password box: passwordInput ();
Single region: radio (), radioList ();
Check box: checkbox (), checkboxList ();
Drop-down box: dropDownList ();
Hidden field: hiddenInput ();
Text Field: textarea (['rows '=> 3]);
File Upload: fileInput ();
Submit button: submitButton ();
Reset button: resetButtun ();
<? Php $ form = ActiveForm: begin (['action' => ['test/getpost'], 'method' => 'post',]);?> <? Echo $ form-> field ($ model, 'username')-> textInput (['maxlength' => 20])?> <? Echo $ form-> field ($ model, 'Password')-> passwordInput (['maxlength' => 20])?> <? Echo $ form-> field ($ model, 'sex')-> radioList (['1' => 'male', '0' => 'female])?> <? Echo $ form-> field ($ model, 'edu')-> dropDownList (['1' => '', '2' => 'high school ', '3' => 'Junior high school'], ['propt' => 'select ', 'style' => 'width: 120px'])?> <? Echo $ form-> field ($ model, 'file')-> fileInput ()?> <? Echo $ form-> field ($ model, 'hobby')-> checkboxList (['0' => 'basketball ', '1' => 'soccer ', '2' => 'badminton ', '3' => 'table tennis'])?> <? Echo $ form-> field ($ model, 'info')-> textarea (['rows '=> 3])?> <? Echo $ form-> field ($ model, 'userid')-> hiddenInput (['value' => 3])?> <? Echo Html: submitButton ('Submit', ['class' => 'btn btn-primary ', 'name' => 'submit-click'])?> <? Echo Html: resetButton ('reset ', ['class' => 'btn btn-primary', 'name' => 'submit-click'])?> <? Php ActiveForm: end ();?>
I hope this article will help you design PHP programs based on the Yii framework.