이 기사의 예에서는 YII2.0의 Activeform 양식 구성 요소의 사용법을 설명합니다. 참고를 위해 모든 사람과 공유하세요. 세부 사항은 다음과 같습니다:
Activeform
텍스트 상자: textInput();
비밀번호 상자:passwordInput();
라디오 버튼: radio(),radioList();
체크박스:checkbox(),checkboxList();
드롭다운 상자: dropDownList();
숨겨진 필드: hideInput();
텍스트 영역: textarea (['rows'=>3]);
파일 업로드: fileInput();
제출 버튼: submitButton();
재설정 버튼: 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'=>'男','0'=>'女']) ?> <? echo $form->field($model, 'edu')->dropDownList(['1'=>'大学','2'=>'高中','3'=>'初中'], ['prompt'=>'请选择','style'=>'width:120px']) ?> <? echo $form->field($model, 'file')->fileInput() ?> <? echo $form->field($model, 'hobby')->checkboxList(['0'=>'篮球','1'=>'足球','2'=>'羽毛球','3'=>'乒乓球']) ?> <? echo $form->field($model, 'info')->textarea(['rows'=>3]) ?> <? echo $form->field($model, 'userid')->hiddenInput(['value'=>3]) ?> <? echo Html::submitButton('提交', ['class'=>'btn btn-primary','name' =>'submit-button']) ?> <? echo Html::resetButton('重置', ['class'=>'btn btn-primary','name' =>'submit-button']) ?> <?php ActiveForm::end(); ?>
이 글이 Yii 프레임워크를 기반으로 한 PHP 프로그램 설계에 도움이 되기를 바랍니다.
위 내용은 관련 내용을 포함하여 YII20의 Activeform 폼 컴포넌트의 사용 예를 소개하고 있으며, PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.