On Tue, Aug 20, 2013 at 10:15 PM, Anthony <abasta...@gmail.com> wrote:

>
>
> I'm not sure we should have created a formstyle called "boostrap", though.
> Instead, we should probably put a formstyle.py in contrib that includes
> several custom formstyles, including ones for Bootstrap 2 and Bootstrap 3.
> Then you would do:
>
> from gluon.contrib.formstyle import bootstrap3
> form = SQLFORM(..., formstyle=bootstrap3)
>
>
I think this should be the way to go.
But it will not be enough, for example, I'm using bootstrap3 with web2py in
my personal feed reader/aggregator
(you can check here http://feeds.uni.me/)
and if you go to the register form, the "Verify Password" field doesn't
pass through the custom formstyle, we will have
to do some css, js or server side dom manipulation, if we want to style
this fields (that feels a little bit hacky, for me).

The custom formstyle that I'm using is this one:

def formstyle_bs3(form, fields):
    ''' bootstrap3 '''
    table = FIELDSET()
    for id, label, controls, help in fields:
        if isinstance(controls, INPUT) and controls['_type'] == 'submit':
            _help = P(help, _class='help-block')
            controls.add_class('btn btn-default')
        elif isinstance(controls, INPUT) and controls['_type'] ==
'checkbox':
            _help = P(help, _class='help-block')
            controls = DIV(controls, _class="checkbox")
        elif isinstance(controls, CAT) and isinstance(controls[0], INPUT):
            controls[0].add_class('form-control')
            _help = P(help, _class='help-block')
        else:
            _help = P(help, _class='help-block')
            controls.add_class('form-control')
        table.append(DIV(label, controls, _help, _class="form_group"))
    return table

It's not a complete and generic implementation, it's just for my specific
need.


Ricardo

-- 

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