I beg your pardon... here it is the corrispondent solution for the
form... but maybe you have better ideas

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])
    #count = 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"))

Il 23/05/13 15:18, Manuele Pesenti ha scritto:
> Hello!
> I found this tricky way to have in evidence required fields in a grid
> defined like the following:
>
> <code>
> 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))grid =
>
> mygrid = SQLFORM.smartgrid(db.mytable)
>
> dressMandatory(mygrid, db.mytable)
> </code>
>
>
> Can you help to do the same with a form like that:
>
> form = SQLFORM.factory(db.mytable)
>
> Thank you in advance
>
> Cheers
>
>     Manuele

-- 

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


Reply via email to