Category Archives: Yii tips

Yii 1.0 Form Label Configuration

This tutorial will help your to add the span, class, style configuration dynamically for the Yii Form Label (Yii Framework 1.x). We can give ajax parameter using the below code. It will helpful for dynamic form requirement and validation. Form Configuration $group_list=array(); $ajax=array(); $ajax[‘type’]=’GET’; $ajax[‘url’]=Yii::app()->createAbsoluteUrl(‘ajax/grouplist’); $ajax[‘update’]=’#’.CHtml::activeId($model,’unit’); $ajax[‘data’]=array(‘id’=>’js:this.value’); $ajax[‘onchange’]=”js:resetunit()”; $group_ajax[‘ajax’]=$ajax; $group_ajax[’empty’]=’Select Group’; $group_ajax[‘class’]=’form-control’; //$group_ajax[‘disabled’]=”disabled”; to disable the dropdownlist […]

Yii CHttpRequest

CHttpRequest is equal to ‘$_SERVER’. we are using ‘$_SERVER’ variable to get the details of request, scripts, headers etc. We can get this information using CHttpRequest class. We can access the CHttpRequest via Yii::app()->request. It will return browser accept types, baseurl, csrftoken, csrftoken name, host name, request type [POST, AJAX, GET, PUT, DELETE], request Uri, […]

Yii Client Script

Here I explained How to add user javascript into yii using clientscript->registerScript function with example. Create Client Script Client Script With Button Action Client Script For User Ajax Request Create Client Script <?php /** * Create Client Script **/ Yii::app()->clientScript->registerScript(“newdownloadbtnjs”,’ /** enter your js code here **/ ‘); ?> Client Script With Button Action <?php […]

Yii ClientScript Css, Js

CClientScript manages JavaScript and CSS stylesheets for views. CoreScript register New Css, Js File Map Single Script Minimize Script File Disable Js, Css Include Js, Css Files Of Extensions register Style Code register Script code CoreScript registerCoreScript method used to include the script files from core script library (From framework library) to application. So we […]

Yii current Url

To Get Current Url Get Action Name Get Controller Name To Get Current Url echo Yii::app()->request->requestUri; Get Action Name //Anywhere Yii::app()->controller->action->id //Inside Controller public function beforeAction($action) { $actionId = $action->id; ………. } Get Controller Name // Anywhere Yii::app()->controller->id //Inside Controller echo $this->getId();

Yii Framework Website List

I added the website list using Yii Framework. 1. http://www.hotellweb.no The first hotel booking website using responsive design and more 2. http://www.stay.com Stay lets you discover exciting attractions, restaurants and nightlife, and build the perfect travel guide together! Get recommendations from friends, or check out our curated travel guides for 130 destinations and more 3. http://noisey.vice.com/en_us Noisey is a […]

Yii hint for CGridview

We can change the cgridview CButtonColumn visible status based on condition. Here i explained to show and hide the action buttons. using “visible” tag We can do this. To show the button set ‘true’ to visible and to hide the button set ‘false’ to visible. array( ‘class’=>’CButtonColumn’, ‘header’ => ‘List of Actions’, ‘template’=>'{view}{update}{delete}{User}’, ‘buttons’=>array( ‘User’=>array( […]

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 […]

Yii Maintenance Mode

This tutorial will useful to change your yiiframework website to maintenance mode. User can access maintenance file only. Maintenance Controller Maintence File Maintenance Controller Make or Point the controller action to maintenance mode. 1 return array( 2 ‘catchAllRequest’=> array(‘site/maintenance’), 3 ………… 4 ………… Maintence File Make or Point the file to maintenance mode. If the condition file_exists() […]

Yii SQL Query To CGridview

CSqlDataProvider implements a data provider based on a plain SQL statement. This tutorial will help you to display the custom sql query result into cgridview as normal crud view. But dont forget to remove the semicolon in custom sql statement Because it will create error on count query. Controller.php <?php ……….. public function actionPending(){ $sql=”SELECT […]