First, you can use the same approach with the grid that you are using with 
SQLFORM, as the grid simply produces a SQLFORM when creating or updating 
records. Note, web2py DOM objects have an .add_class() method, so you can 
use that instead of manually extracting and updating the "_class" attribute.

Another option is to specify a custom widget for the field in question, 
either when the db table is defined or later:

Field('cantidad', widget=lambda f, v: SQLFORM.widgets.string.widget(f, v, 
_class='col-sm-3', _maxlength=8))

Anthony

On Wednesday, July 4, 2018 at 6:31:50 AM UTC-4, JSalvat wrote:
>
> Hi,
>
> How to custom an input field width   class='col-sm-x'  in create/edit 
> forms that come from SQLFORM.grid
>
> On SQLFORM can be done this way:
>
> form = SQLFORM(db.movimiento)
> if form.element('#movimiento_cantidad'):
>      wclass = form.element('#movimiento_cantidad')['_class']
>      form.element('#movimiento_cantidad')['_class'] = wclass + ' col-sm-3'
>      form.element('#movimiento_cantidad')['_maxlength'] = 8
>
> but when the form is generic from SQLFORM.grid  how can it be done?
>
> Thanks for any help if it could be done.
>

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