MainelyDesign.com Blog

Forms Tagged Blog Posts

Which Submit Button was Clicked in CakePHP? Use Name.

Posted on 03/04/2010 at 12:01 pm | Viewed 26,199 times | 2 comments

If you want to have multiple submit buttons that make a form do different things there's a simple way to do this.  The name of the submit button that was clicked by the user will be sent (via POST) with all the other POSTed data.  This is very handy if you want to have a cancel button and continue button. In CakePHP the name of the button won't be in $this->data, but it's easy enough to get...

A Really Good Implementation of Captcha

Posted on 09/22/2009 at 02:45 pm | Viewed 11,681 times | 0 comments

Awesome Captcha Implementation

I just experienced a version of Captcha that I actually like.  Instead of having to type in jumbled letters and phrases or answering simple questions, Service2Client actually asks you to identify the color of the letter in a certain position.  Not only does it fool spambots (I would assume anyway) but it's pretty easy to understand.

Date Input Using Cakephp Form Helper

Posted on 09/09/2009 at 03:29 pm | Viewed 32,829 times | 3 comments

I always forget what exactly needs to happen in order for CakePHP's form helper to work with date input fields.  I'm sick of tearing through old source code and looking at the official CakePHP docementation site.  Here's how to get it to work...

Date Inputs Using the Form Helper:

$current_year = date('Y');
$max_year = $current_year + 2;
echo $form->input('dateSelectBoxes', array('type'=>'date', 'selected'=>$unix_timestamp, 'empty'=>true, 'minYear'=>2009, 'maxYear'=>$max_year));

Checkbox - setting the default state

Posted on 04/17/2009 at 08:31 am | Viewed 14,921 times | 0 comments

I ran across a rather simple problem (I thought) that took a little searching to figure out.  All I had to do was create a checkbox form input that I wanted to have checked by default.  I tried 'default'=>'checked', which didn't work.  I also tried 'checked'=>true and 'checked'=>1, but that works every time, even if validation fails and the user had unchecked the checkbox, it will be checked again (Not good usability). 

Full Tag List

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design