Here is a typical, simple form done with cake’s form helpers:
[code language=”php”]echo $this->Form->create(‘Article’, array(‘action’ => ‘test’));
A quick example of some automagic goodness…
Let’s say we need to to build an “add Post” form and allow the user to pick some tags for the Post.
Note, this article was written a long time ago for CakePHP version 1.x … many of the points described here still apply in the latest 2.x versions of CakePHP.
1. Save() does not work!Sometimes it happens that save() fails without any obvious reason. Your…
A nice little trick to check if you have some errors in the view is to use the $session object.
Try this (in the view): pr($this->validationErrors) or pr($session->validationErrors), be sure to actually have some errors in the form…
In the past I’ve often kept some data such as a list of states or countries in the DB and used that to populate my forms. After some random thinking I’ve found no good reason to utilize the DB for such a thing. This kind of a list is not very long and…
One question that I’ve seen come up a few times is: “How do I handle multiple checkboxes in a form?”The only trick here is the way you name your checkbox form element. Let’s consider an example where you’d like to select multiple messages (by using checkboxes) and then delete these messages…