Making CakePHP Form Helper Compatible with Bootstrap

I’ve been struggling getting inputs created by the CakePHP Form Helper to function sanely with a bootstrap admin theme we’re using at work. When I first looked at the form helper I thought it was silly to using PHP to generate HTML. But there are good reasons to do this:

  1. Less HTML to change
  2. Bind CSS classes to form elements in a single location
  3. Integration with CakePHP security components like CSRF.
  4. Baking templates will use the Form Helper by default.

Since we use customize bake scripts to automate CRUD views as well as the security component I needed to roll up my sleeves and make the Form Helper compatible with our Bootstrap theme.

Our default form behavior looks this:

This is not what we want and it might lead you to wrap HTML around this form helpers. This is a waste of key strokes and makes our HTML far to static and thus resistant to future UI changes. Using form templates we can adjust the form helpers default template and achieve a much more agile UI.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.