OK, except I have other apps where required=True works as expected, that 
is, it causes a validation failure when the field is submitted empty. 

These other apps are running on the same Web2py instance, so this is 
puzzling.

On Tuesday, November 11, 2014 10:54:21 AM UTC-5, Willoughby wrote:
>
> I think one is for forms, one is for the insert. From the book:
> "Notice that requires=... is enforced at the level of forms, required=True 
> is enforced at the level of the DAL (insert), while notnull, unique and 
> ondelete are enforced at the level of the database. While they sometimes 
> may seem redundant, it is important to maintain the distinction when 
> programming with the DAL."
>
> On Tuesday, November 11, 2014 10:36:41 AM UTC-5, Cliff Kachinske wrote:
>>
>> This field will not fail validation when submitted empty. Web2py 2.8.2 
>> with lazy tables and archiving.
>>
>> REQUIRE_MSG = SPAN('Required', _style="color:orange;")
>>
>>        Field(
>>             'problem_title', 
>>             length=512,
>>             required=True,
>>             comment=REQUIRE_MSG,
>>              )
>>
>> Written this way, it works.
>>
>>        Field(
>>             'problem_title', 
>>             length=512,
>>             required=True,
>>             comment=REQUIRE_MSG,
>>             requires=IS_LENGTH(
>>                 minsize=1,
>>                 maxsize=512,
>>                 error_message='Problem title cannot be empty. Max 512 
>> characters.'
>>                 )
>>        )
>>
>> I didn't expect this ...
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to