On Wednesday, April 25, 2018 at 5:56:08 PM UTC-4, Alfonso Serra wrote:
>
> Thanks Anthony. It worked but now it always validates no matter what.
>
> I have passed
>
> # request.vars
> <Storage {'rooms': 'asd'}>
> request.vars._formname = "get_rates"
>
> print "accepts:", form.accepts(request.vars, session=None, dbio=False,
> formname="get_rates")
> print "validate:", form.validate(request_vars=request.vars, session=None,
> formname="get_rates")
>
> And the form is accepted on both cases.
>
What validators did you define?
> Is not, at least, the variable type compared?
>
Not without validators.
> Would it make sense to modify the Field class to add initial validators
> when it is instantiated, or have in mind the field type and requirement?
>
When using db.define_table() with a regular DAL instance, there are some
default validators
added:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-types.
However, this does not happen when simply using SQLFORM.factory.
> I may be wrong but havent seen this behaviour on a post submit. Does this
> only happen on get submits?
>
Same with POST or GET if using SQLFORM.factory.
Note, internally, SQLFORM.factory uses DAL(None) to generate a dummy DAL
instance and table definition. For some reason, with DAL(None), the default
validators (noted above) are not applied. Feel free to submit a Github
issue about that, or maybe even make a pull request to change that behavior
(I haven't looked at the code to see why it works that way now).
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 [email protected].
For more options, visit https://groups.google.com/d/optout.