ketan is right, a possible gotcha is that for a checkbox, I found the
only way to get it to behave right is to use
var $validate = array(
'terms_and_conditions'=> '/1/'
)
setting 'required' = true or 'required'= VALID_NOT_EMPTY wouldnt work
for me.
This is not a bug (I think), more to do with the nature of the
problem.
luke
On Aug 31, 1:26 pm, Ketan Patel <[EMAIL PROTECTED]> wrote:
> Even if you do not have a field in the Database, you can add a field
> the validation array in the model and this would do the check for you.
> So in your model 'classname' add 'AcceptRules' field to the validation
> array. Doing so would not have any side-effects as I do it all the
> time.
>
> Ketan
>
> On Aug 30, 10:03 am, MikeK <[EMAIL PROTECTED]> wrote:
>
> > Using the latest1.2alpha cakePHP I am trying to add a simple
> >checkboxto 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 manuallyvalidatein 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
-~----------~----~----~----~------~----~------~--~---