Following the post (http://goo.gl/PLeNJR) for ACL: Checking Permissions in Views like some others I faced a “undefined index User…” and some other PHP warnings when trying to implement this example. After doing some testing following the working code I came…
Category: CakePHP
Containable with mixed arguments, the CakePHP Beauty!
Here’s an example of CakePHP Containable behaviour. Although, it was not a very complex find call but the beauty of the containable is this that you can fetch records using “tricky ways” which normally may not be possible with straight…
How to paginate a different model with options in CakePHP
Assume you are on a LogsController which has Log as the default model and wanted to paginate another model LogColumn. Here’s How it goes:
How to get model name from controller in cakephp
Suppose we have $controller as an object for our controller class. We can do the following to get the model class: [code]$modelName = $controller->modelClass;[/code]
An example of CakePHP complex find conditions
Setting complex ‘find’ conditions in CakePHP can be tricky. I picked an example of Cakephp complex find conditions from one of my CakePHP projects. I wanted to list all auctions which are “not closed” and whose’ end date/time is greater…
Installing PHPUnit in wamp in Windows7
Installing PEAR package manager Add php directory to your Windows’ Environment Variables PATH, if it is not already added. My wamp php path is “C:\wamp\bin\php\php5.3.13”. Check Adding to Environment Variables Path if you are not sure how to add a…
Setting id of input wrapper div in cakephp and hiding by default
It might be a simple thing for most of CakePHP pro’s but at the same time it could be a tricky thing for CakePHP newbies. I just caught one newbie CakePHP developer of my team spending time on figuring this…
How to get current theme name or theme working in cakephp
Making theme set and available by setting theme related properties in controller Prior to cakephp 2.0 class UserController extends AppController { var $view = ‘Theme’; //tells controller to use “ThemeView” class instead of the default “View” class var $theme =…
Conditional skip for a field from model validation in a cakephp controller
In a controller, a table field could be skipped from model validations by editing the “validate” property of a model. For example, i have a “date” validation for “dob” (date of birth) field set in my “User” model.
A note on $form->dateTime(‘field_name’) generating offset warning in CakePHP
This is a note on $form->dateTime(‘field_name’) generating offset warning i.e. “Notice (8): Undefined offset: 1 [CORE/cake/libs/view/helpers/form.php, line 1836..“. If your “date” form field in a view is generating a similar warning you may need to look into the following scenario.