Tag Archives: cakephp tips & tricks

Archive

Making now() date filter working and complex find conditions in CakePHP

Supplying complex find conditions in CakePHP can be tricky. I have got an example from my current project.

I wanted to list all auctions which are “not closed” and whose’ end date/time is greater that the current date/time. I can use the following statement. Continue reading

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 out thus adding it here for future reference. I hope it helps someone else as well. Continue reading

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. Continue reading

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. Continue reading

A tip on CakePHP find list with related model conditions

You will need to add recursive=>(value) to the $params when you need to get a ‘list’ of table items using related model conditions.

Referring to the example depicted here, http://book.cakephp.org/view/1022/find-list let’s say you perform the following query: Continue reading