Yii Framework

Getting error: Bad Request The CSRF token could not be verified: when CSRF has been enabled in the Yii Framework

G

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 a form. Add  ‘YII_CSRF_TOKEN’ => Yii::app()->request->csrfToken to the params array in the linkButton Example  <?php echo CHtml::linkButton('Register', array('submit' => ' '...

How to set the Page Title in Yii Framework 1.1.x

H

In your main layout file always have the following code between the title tag in order to display the title <title><?php echo CHtml::encode($this->pageTitle); ?></title> Please note that conditional statements can also be use within the title tag to make displaying of the title more dynamic. You can set the title in your Controller or View files by using something similar...

How to add JavaScript to you view files using the Yii Framework

H

Add the JavaScript code as below to your view $js = Yii::app()->getClientScript();   $js->registerScript(   'my-javascript-id',   'var value = "Hello World";   alert(value);',   CClientScript::POS_END ); Yii’s CClientScript is used to place JavaScript to your views. The arguments of register script are as follows: The first argument uniquely identifies your script The second argument...

How to Embed CSS into a View using the Yii Framework 1.1

H

This can be done using the registerCss() method of the CClientScript class. CClientScript manages JavaScript and CSS stylesheets for views.  registerCss()registers a piece of CSS code. Place code similar to the example code below in your View Yii::app()->clientScript->registerCss('customCSS',<<<CSS    li {     font-weight: normal;    } CSS ); In the code above the first parameter...

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me