On Wednesday, December 16, 2015 at 4:53:16 AM UTC-5, Alfonso Serra wrote:
>
> Im trying to create a formstyle, when the form is submitted without 
> introducing any value it skips any kind of validation and, without being 
> accepted, tries to perform db changes. Eventually i get an error ticket 
> like:
>
> pymysql.err.InternalError'> (1048, u"Column 'salida' cannot be null")
>
>
> This is the style:
>
> def formstyle_stardom(form, fields):
>
>     parent = CAT()
>
>     for fieldname in form.fields:
>         field = form.table[fieldname]
>
>         if field.type != "id":
>             parent += LABEL(fieldname, _for=fieldname) + INPUT(_name=
> fieldname, value=field.default)
>

If you're going to build everything completely from scratch, then you are 
responsible for adding the validators to the form controls. So, you need 
something like:

    INPUT(_name=fieldname, value=field.default, requires=field.requires)

If you use the "controls" object passed into the formstyle function as part 
of the "fields" object, this is done for you automatically.

Note, if you want custom widgets, a better approach might be to create 
custom widget functions/classes and use the "widget" argument to Field() 
when defining your models.

Anthony

-- 
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