Yii Form And Html Tutorials

CHtml ListBox

CHtml::listBox() function is used for creating ListBox in yii framework. This post will help you to understand about how to create ListBox in different method, How to assign value, how to get ListBox value in controller, ListBox value from database in yii framework.SyntaxListBoxStatic Values For ListBoxListBox Values From DatabaseListbox GroupListbox Values In ControllerSyntax public static string activeListBox(CModel $model, string $attribute, array $data, array $htmlOptions=array ( )) [OR] public static string […]... Read More »

CHtml FileField

Using CHtml class we are creating fileField in yii framework. This post will help you to understand about how to upload file in different method, how to get and save the uploaded file in controller, file validation in model yii framework.SyntaxactiveFileField With CHtmlfileField With FormfileField With CHtml (Without Model Name)File In ControllerDONT FORGET multipart/form-data <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'files-form', 'htmlOptions'=>array('enctype' => 'multipart/form-data'), )); ?> Syntax public static string activeFileField(CModel $model, string […]... Read More »

CHtml Radio Button List

Using CHtml class we are creating radioButtonList in yii framework. This post will help you to understand about how to create radioButtonList in different method, How to assign value, how to get radioButtonList value in controller, radioButtonList value from database, radioButtonList validation in model and radion button list style in yii framework.radioButtonListradioButtonList Validation In ModelradioButtonList Value In ControllerSelected radiobutton List Value From Databaseradiobutton List StyleradioButtonListUsing below code, we can create […]... Read More »

CHtml Radio Button

Using CHtml class we are creating radioButton in yii. This post will help you to understand about how to create radioButton in different method, radioButton properties, array value, how to get radioButton value in controller and radioButton validation in model.radioButtonChecked PropertiesradioButton ValueradioButton Validation In ModelGet radioButton Value In ControllerRadioButtonactiveRadioButton With CHtml <?php echo CHtml::activeRadioButton($model,'attribute',array()); ?> CHtml activeRadioButton generates a radio button for a model attribute.radioButton With Form <?php echo $form->radioButton($model,'attribute'); […]... Read More »

CHtml Checkbox

Using CHtml class we are creating checkbox in yii. This post will help you to understand about how to create checkbox in different method, checkbox properties, array value, how to get checkbox value in controller and checkbox validation in model.CheckBoxChecked PropertiesCheckbox ValueCheckbox Validation In ModelGet Checkbox Value In ControllerCheckBoxactiveCheckbox With CHtml <?php echo CHtml::activeCheckBox($model,'attribute',array()); ?> CHtml activeCheckbox generates a check box for a model attribute.Checkbox With Form <?php echo $form->checkBox($model,'attribute'); […]... Read More »

CHtml Button

CHtml is a static class and it is used to generate a button.public static string button(string $label='button', array $htmlOptions=array ( )) CHtml class used in CFormButtonElement to represents a form button element. CFormButtonElement have the 8 types of button types. The types are htmlButton, button, submitButton, imageButton, resetButton and link button.htmlButton: Type-buttonhtmlButton: Type-submithtmlButton: Type-resetbutton: Type-buttonbutton: Type-submitbutton: Type-resetsubmitButtonimageButtonresetButtonlinkButtonhtmlButton: Type-button <?php echo CHtml::htmlButton('HTML BUTTON',array( "id"=>'chtmlbutton', "class"=>'chtmlbuttonclass') ); ?> Output <button type="button" name="yt0" […]... Read More »

Yii Hint For Form Radio Button

This tutorial will help you to style the radio button list on form. Using template, separator, style and label options, We can give proper style to radio button. <div class="row"> <?php echo $form->labelEx($model,'isactive'); ?> <?php echo $form->radioButtonList( $model, 'isactive', array('1'=>'Active','0'=>'Inactive'), array( 'template'=>'{input}{label}', 'separator'=>'', 'labelOptions'=>array( 'style'=>'padding-left:13px;width: 60px;float: left;' ), 'style'=>'float:left;', ) ); ?> <div style="clear: both;"></div> <?php echo $form->error($model,'isactive'); ?> </div>... Read More »

CHtml Checkbox List

Using CHtml class we are creating checkBoxList in yii. This post will help you to understand about how to create checkBoxList in different method, How to assign value, how to get checkBoxList value in controller, checkBoxList value from database, checkBoxList validation in model and checkbox list style.checkBoxListcheckBoxList Validation In ModelcheckBoxList Value In ControllerSelected checkbox List Value From Databasecheckbox List StylecheckBoxListUsing below code, we can create checkbox list in different way. […]... Read More »

CHtml radioButtonList Ajax Submit

I added the code to submit the yii form When we select the value from Chtml radio button list box. <div class="search-form" style="display:block"> <div class="wide form"> <?php $form=$this->beginWidget('CActiveForm', array( 'action'=>Yii::app()->createUrl($this->route), 'method'=>'get', )); ?> <div class="row"> <?php echo $form->labelEx($model,'type'); ?> <?php $types=array("1"=>"Type1","2"=>"Type2"); echo $form->radioButtonList( $model, 'type', $types, array( 'template'=>'{input}{label}', 'separator'=>'', 'labelOptions'=>array('style'=>'padding-left:13px'), 'style'=>'float:left;', 'onclick'=>CHtml::ajax(array( 'success'=>"$('.search-form form').submit()", )) ) ); ?> </div> </div> </div>... Read More »