Hi.
Sorry for all these questions. If it's any consolation, I'm putting
together a brief guide for making forms in CakePHP with the form
helper, which is one of the reasons I want to make sure I'm doing
things the right way.
Anyway, my question is about how I should add the option of "none of
the above" in a select element.
I know that to add an option of "please select something," I just
write something like this in the view:
echo $form->input('person_id', array('empty' => EMPTY_DROPDOWN));
(I've defined EMPTY_DROPDOWN in app/config/bootstrap.php so I can
change all the "Please select" messages in one fell swoop.)
So that makes sure that the user has to select *something*, which is
great, but what if I want to give them the option of "none of the
above," as long as they've put some thought into it and actively
selected it?
I'm working on doing it like this, replacing this line in the
controller:
$this->set('people', $this->Thing->People->generateList());
...with this one:
$this->set('people', am(array('NULL' => 'None'), $this->Thing->People-
>generateList()));
I can also add the post-submission code to look out for the string
'NULL' instead of an ID, but is there a more official way of doing it
that I'm supposed to adhere to?
Thanks for any advice,
Zoe.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---