Thanks Manuele.  I am hoping that a generic onrender callback for default 
widgets will simplify this.  

On Tuesday, August 27, 2013 5:38:37 AM UTC-5, Manuele wrote:
>
>  Il 25/08/13 00:37, mr.freeze ha scritto:
>  
> I want to take advantage of bootstrap's form validation classes so I need 
> to add a class to the field.
>
> if could be of any help that's the ugly way how I solved it locally :)
>
> def dressMandatory(grid, table):    """ Special representation for mandatory 
> fields in grid """    for fieldname in table.fields:        myid = 
> '_'.join((table._tablename, fieldname, ))        # icon = 
> I(_class="icon-warning-sign")        app = '' # SPAN(icon, _class="add-on") 
> if table[fieldname].required else ''        class_value = "control-group 
> warning" if table[fieldname].required else ''        grid.elements('#%s' % 
> myid, replace=lambda el: DIV(DIV(TAG.nobr(el, app), _class="input-append"), 
> _class=class_value))
> def dressMandatoryInForm(form, *tabs):    """ Special representation for 
> mandatory fields in form """    tabs_fields = [[t[f] for f in t.fields if f 
> != t._id.name] for t in tabs]    fields_list = sum(tabs_fields[1:], 
> tabs_fields[0])    m = form.elements()[0].elements    for field in 
> fields_list:        if field.writable and field.readable and not 
> field.compute:            if field.required:                m('#no_table_%s' 
> % field.name, replace=lambda el: DIV(DIV(el, _class="input-append"), 
> _class="control-group warning"))
>
>
>  

-- 

--- 
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/groups/opt_out.

Reply via email to