Home > Backend Development > PHP Tutorial > YII2.0 Activeform form component usage example, yii2.0activeform_PHP tutorial

YII2.0 Activeform form component usage example, yii2.0activeform_PHP tutorial

WBOY
Release: 2016-07-12 09:01:14
Original
954 people have browsed it

Usage examples of Activeform form components in YII2.0, yii2.0activeform

This article describes the usage of Activeform form components in YII2.0. Share it with everyone for your reference, the details are as follows:

Activeform

Text box: textInput();
Password box: passwordInput();
Radio button:radio(),radioList();
Checkbox:checkbox(),checkboxList();
Drop-down box: dropDownList();
Hidden field:hiddenInput();
Text area: textarea(['rows'=>3]);
File upload: fileInput();
Submit button:submitButton();
Reset button: resetButtun();

<&#63;php
$form = ActiveForm::begin([
  'action' => ['test/getpost'],
  'method'=>'post',
  ]); &#63;>
<&#63; echo $form->field($model, 'username')->textInput(['maxlength' => 20]) &#63;>
<&#63; echo $form->field($model, 'password')->passwordInput(['maxlength' => 20]) &#63;>
<&#63; echo $form->field($model, 'sex')->radioList(['1'=>'男','0'=>'女']) &#63;>
<&#63; echo $form->field($model, 'edu')->dropDownList(['1'=>'大学','2'=>'高中','3'=>'初中'],
['prompt'=>'请选择','style'=>'width:120px']) &#63;>
<&#63; echo $form->field($model, 'file')->fileInput() &#63;>
<&#63; echo $form->field($model, 'hobby')->checkboxList(['0'=>'篮球','1'=>'足球','2'=>'羽毛球','3'=>'乒乓球']) &#63;>
<&#63; echo $form->field($model, 'info')->textarea(['rows'=>3]) &#63;>
<&#63; echo $form->field($model, 'userid')->hiddenInput(['value'=>3]) &#63;>
<&#63; echo Html::submitButton('提交', ['class'=>'btn btn-primary','name' =>'submit-button']) &#63;>
<&#63; echo Html::resetButton('重置', ['class'=>'btn btn-primary','name' =>'submit-button']) &#63;>
<&#63;php ActiveForm::end(); &#63;>

Copy after login

I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.

Articles you may be interested in:

  • Yii2 uses Bootbox plug-in to implement custom pop-up windows
  • Learn YII2 framework from scratch (4) Extension plug-in yii2-kartikgii
  • Learn the YII2 framework from scratch (3) Extend the plug-in yii2-gird
  • Learn the YII2 framework from scratch (2) Install the extension plug-in through Composer
  • Use the drop-down menu in the yii2 framework Automatic search yii-widget-select2 instance analysis
  • Method of using Active Record mode in yii2
  • Implementation method of adding verification code in yii2
  • Yii2 framework references the date in bootstrap Methods of plug-in yii2-date-picker

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1089937.htmlTechArticleUsage examples of the Activeform form component of YII2.0, yii2.0activeform This example describes the Activeform form component of YII2.0 usage. Share it with everyone for your reference, the details are as follows: Activef...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template