How about the jQuery validation plugin?
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
That way the form doesn't even get submitted if the checkbox isn't
checked.
On Aug 30, 8:03 am, MikeK <[EMAIL PROTECTED]> wrote:
> Using the latest 1.2 alpha cakePHP I am trying to add a simple
> checkbox to a form to indicate the user's acceptance of certain
> conditions etc.
>
> ex: echo $form->checkbox('AcceptRules');
>
> However 'AcceptRules' is not a valid field in the model or database.
>
> Currently I manually validate in the controller by:
>
> if ($this->data['Classname']['AcceptRules'] == 1) then it is checked,
> if == 0 then not checked. Please note there is no call to "Save" any
> contents entered on this form, the form only gets the user's
> acceptance of the rules.
>
> My validation code essentially returns the user back to the view with
> a flashmsg if he does not check the box.
>
> What I really want is validation similar to what I get for a simple
> text field when I specify a field in the DB/model is to be NONBLANK
> for example, and then my ensuing "save" call in the controller fails
> and when I return to the view it throws a nicely formatted error msg
> below the field on return to the form (using nothing more then form-
>
> >input().
>
> How can I accomplish this for a "non-existant" field on a method where
> there is no save call? I'm trying to avoid synthesizing what seems to
> be built-in very nicely for fields in my models.
>
> I apologize in advance if this has been answered and appreciate the
> advice.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---