PHP Frameworks

Disabling the Layout and the View in cakePHP

To disable the view and the layout in cakePHP set autoRender to false within the appropriate action in your controller $this->autoRender = false; To only disable the layout in cakePHP set the layout to false $this->layout = false; And to only disable the view for an action call the render method and set the parameter to false $this->render(false);
Ian Carnaghan
13 sec read

How to check in Controller which validation rule failed…

Put the code below in your controller and replace the model name with the appropriate model name against which to check. $errors = $this->ModelName->invalidFields();...
Ian Carnaghan
10 sec read

How to find the value of a single field…

Use the model method field if no matching data is found it returns false. Example   $this->Model->id = 10;   $this->Model->field('name'); The example above displays the...
Ian Carnaghan
10 sec read

How to create a back link using the Yii…

In the view that you wish to use add the following code for the back link. CHtml::link('Back',Yii::app()->request->urlReferrer);
Ian Carnaghan
5 sec read

Getting error: Bad Request The CSRF token could not…

Getting error: Bad Request The CSRF token could not be verified: when CSRF has been enabled in the Yii Framework and I’m clicking on a linkButton within...
Ian Carnaghan
16 sec read

How to create a Email link using the Yii…

In the view that you wish to use add the following code for the Email link. CHtml::mailto($data->email) NOTE: $data->email contains the email address, replace this variable...
Ian Carnaghan
9 sec read

How to include JQuery in the Yii Framework

You can add the below code anywhere in your Yii Application and JQuery will be included in the rightful place in your application Yii::app()->clientScript->registerCoreScript('jquery');
Ian Carnaghan
6 sec read

How to disable JQuery in the Yii Framework 1.1.x

Include the following code anywhere in your application   
Ian Carnaghan
14 sec read

How to get the server name using the Yii…

Use the code below to obtain the server name Yii::app()->request->serverName
Ian Carnaghan
3 sec read