CakePHP form display
I'm pretty new still when it comes to cakePHP, but there's a few things that I've noticed in my limited exposure that screams a developer created this. Throughout my job I learned that my foremost expectations of "web developers" is completely not true. I was under the impression that everyone in web development (whether they focused on design or development) could build a fully dynamic website. Sure, people focusing in development may make some odd design and layout issues, but he/she would still get the job done.
Much to my surprise, my colleagues aren't all like that. We have some amazing developers who just barely know CSS, and we have designers that don't understand how to loop over a query result. But we do make an excellent team.
The first thing that jumped out at me about cakePHP was how it treats forms using it's form helper. I know of and have read lots of "the correct way to semantically mark up a form" articles. So that means I've come across ones that say you should wrap every label/input combination inside either a fieldset or a div, but I don't agree with that mentality. You can accomplish the same thing by grouping related fields inside fieldsets and using CSS to position your labels and inputs accordingly.
I first used the form helper to output a simple login form:
echo $form->create('User', array('action' => 'login'));
echo $form->input('username');
echo $form->input('password');
?>
The designer I was working with at the time let me know that there was a <div> class="input text"</div>
surrounding both the inputs. To him, this was unacceptable. He blamed me, I said I didn't do add them, he still blamed me. And after I shared the code with him through the greatest code editor ever, coda, we set off to find out where those blasted divs were coming from.
This was the first time I really jumped into the underlying code of cake. It was quite intense. After much searching and even more throwing of stress balls around the office, we found it. One little line in the form helper.
Now keep in mind that this is on cakePHP version 1.2RC2 and the form helper was last modified @lastmodified $Date: 2008-01-02 00:33:52 -0600 (Wed, 02 Jan 2008)
, take a look at line 554 and you'll notice the following.
$div = true;
See that line that sets div equal to true? I simply switched that to false and had an application-wide setting that wouldn't wrap my label/input duals with unneeded divs.