CakePHP No markup with formhelper input

Just a short blog post about CakePHP, I see loads of people around me who don’t want any markup like DIVS or LABELS around their form input elements. There are plenty reasons you don’t want those markup, for example when you need your form in a table.

I see colleagues using $form->select(); or $form->radio(); to avoid all the markup, but there’s a simple trick to hide all the additional elements and still benefit from all the magic features of $form->input();

Just add two parameters in the input options:

1
2
3
4
5
6
<?php
echo $this->Form->input('title', array(
'div' => false,
'label' => false
));
?>