Great Anthony!

Field('year', 'integer', label='Year',
      widget=lambda f, v: SQLFORM.widgets.string.widget(f, v, _type='number'
))

worked perfectly!

Thanks!

2017-09-11 19:59 GMT-03:00 Anthony <abasta...@gmail.com>:

> On Monday, September 11, 2017 at 4:30:40 PM UTC-4, Fabiano Almeida wrote:
>>
>> Hi @ll!
>>
>> How to use HTML5 widgets on SQLFORM.factory?
>>
>> I have this peace of code:
>> form = SQLFORM.factory(Field('year', 'integer', label='Year'))
>>
>
>> I like use this HTML5 input type="number" widget.
>>
>
> You can do:
>
> Field('year', 'integer', label='Year',
>       widget=lambda f, v: SQLFORM.widgets.string.widget(f, v, _type=
> 'number'))
>
> You could instead use SQLFORM.widgets.integer.widget (which is the default
> for integer fields), but that would set class="integer", which would
> activate web2py's built-in integer validator, which you may not want.
>
> 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.
>

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