That's what I imagined too, but this example field has a default of NULL yet it 
is coming through as required. It seems that adding a validation rule (in this 
case maxLength) trips the form helper up and it's displayed as required.

I get your point about moving the logic to an attribute on the form, but I'd 
prefer to understand what's going on and let the form helper do its stuff but 
in the right way.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 23 Nov 2011, at 11:51, euromark wrote:

> 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 <[email protected]> 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
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to