Easiest way to make a form in CakePHP

Share this post:

The easiest way to make the HTML for a simple form is to use CakePHP's built-in FormHelper. Once you get your model and table set up with the fields you need, a little shortcut is to use the inputs() function so that you don't have to type out each individual field input:

echo $this->Form->create('Post');  
echo $this->Form->inputs();  
echo $this->Form->end('Submit');  

This method puts Cake's automagic form elements to work and will save some time and shave off a couple lines of code if your form isn't too complicated.


comments powered by Disqus