YiiCActiveFormの詳細



Yii Cactiveform Detailed



1.頭

$form=$this->beginWidget('CActiveForm', array( 'id'=>'ueb_ebay_online_listing_bidding-form', 'enableAjaxValidation' => false, //Is it ajax verification 'enableClientValidation' => true, //Whether client authentication 'clientOptions' => array( 'validateOnSubmit' => true, //Submit button verification 'validateOnChange' => true, //Value change verification 'validateOnType' => false, 'afterValidate' => 'js:afterValidate', ), 'action' => Yii::app()->createUrl($this->route,array('id'=>$model->id)), 'htmlOptions' => array( 'class' => 'pageForm', ) )) ?>

2.radioButtonListがデフォルトで選択されています



The default is before the controller $model->is_open= 1 //Just add this sentence to set the default value. <div class='row'> echo $form->labelEx($model,'is_open') ?> echo $form->radioButtonList($model,'is_open',['0'=>'no','1'=>'Yes'], array('separator'=>'') ) ?> echo $form->error($model,'is_open') ?> div>

3.ラジオボックス/チェックボックスを使用して、自動行折り返しを削除します

<div class='row'> echo $form->labelEx($model,'is_open') ?> echo $form->radioButtonList($model,'is_open',['0'=>'no','1'=>'Yes'], array('separator'=>'') ) ?> echo $form->error($model,'is_open') ?> //separator is empty

4.長さを設定します



<div class='row'> echo $form->labelEx($model,'id') ?> echo $form->textField($model,'id',array('size'=>60,'maxlength'=>128)) ?> echo $form->error($model,'id') ?> div>

5、textField

public string textField(CModel $model, string $attribute, array $htmlOptions=array ( )) $model CModel the data model $attribute string the attribute $htmlOptions array additional HTML attributes. {return} string the generated input field

6、dropDownList

<div class='row'> echo $form->labelEx($model, 'status') ?> echo $form->dropDownList($model, 'status',array(1=>'Yes',0=>'no'),array( 'style'=>'width:150px', 'prompt'=>'please choose' //Drop down the first item )) ?> echo $form->error($model, 'status') ?> div>

5.フィールド検証に合格すると、非同期要求が送信されます