Wednesday, November 23, 2011

Re: Validation rules

I think its the database schema - if you set default NULL or default
NOT NULL
although I always thought of this as not very helpful (since the forms
are usually not 1:1 what the schema defines)

so in 1.3 I hacked the form helper to avoid adding those rules
automatically.
if I want them to, I would add (required=>true) in the form input
options array manually.

In 2.0 I didnt yet figure out how to avoid the required attribute.
but since some browsers (like chrome) do automatically trigger js
validation there are
now other unwanted sideeffects, too. like js validation differing from
the real model validation.
quite annoying.


On 23 Nov., 12:43, Jeremy Burns <jeremybu...@classoutfit.com> wrote:
> This seems like such a basic question but it often gets me. What is
> the logic that determines whether the form helper marks a field as
> required or not? For example, I have a varchar field that can be null
> and accepts up to 100 characters. I have set a maxLength validation
> rule (that also has required => false, just for good measure). In my
> mind this is not a required field, but the form helper thinks it is.
> All I want to do is make sure the max limit is not exceeded. Removing
> the validation rule removes the required flag from the form. Where can
> I find the logic and how can I adjust it at 'run time'?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate