we should really abandon this format and come with something more user 
friendly

On Thursday, 19 May 2016 05:42:56 UTC-5, Mirek Zvolský wrote:
>
> For me was problem with formstyle=bootstrap3_inline that each field is to 
> much high: just first 5-7 items (from lets say ~20 form fields) were 
> visible on the standard monitor.
>
> Now I use this as clone of the inline style:
>
> Problem is the movement of the label (with control-label css class) to 
> much to down.
> In next code I have 'control-label-sm' as default css class, however this 
> class I haven't defined yet. The labels display well but left justified. At 
> this time I fix this issue with JavaScript:
> $('label').css('text-align', 'right');
>
> I think it will not work from private/appconfig.ini (because it is not 
> registered formstyle in gluon/sqlhtml.py) and it the parameter formstyle in 
> form() or SQLFORM.grid() must be used:
> formstyle = formstyle_bootstrap3_compact_factory()
>
> So if somebody is interested, he/she can try it.
> But it is not to much tested yet.
>
> def formstyle_bootstrap3_compact_factory(col_label_size=2, col_help_size=6,
>                                          input_class='input-sm', 
> control_label='control-label-sm'):
>     """formstyle = formstyle_bootstrap3_compact_factory()
>     """
>     def _inner(form, fields):
>         form.add_class('form-horizontal')
>         label_col_class = "col-sm-%d" % col_label_size
>         col_class = "col-sm-%d" % (12 - col_label_size - col_help_size)
>         offset_class = "col-sm-offset-%d" % col_label_size
>         help_class = "col-sm-%d" % col_help_size
>         parent = CAT()
>         for id, label, controls, help in fields:
>             # wrappers
>             _help = DIV(SPAN(help, _class='help-block'), _class="%s" % 
> (help_class))
>             # embed _help into _controls
>             _controls = DIV(controls, _class="%s" % (col_class))
>             if isinstance(controls, INPUT):
>                 if controls['_type'] == 'submit':
>                     controls.add_class('btn btn-primary')
>                     _controls = DIV(controls, _class="%s %s" % (col_class, 
> offset_class))
>                 if controls['_type'] == 'button':
>                     controls.add_class('btn btn-default')
>                 elif controls['_type'] == 'file':
>                     controls.add_class('input-file')
>                     controls.add_class(input_class)
>                 elif controls['_type'] in ('text', 'password'):
>                     controls.add_class('form-control')
>                     controls.add_class(input_class)
>                 elif controls['_type'] == 'checkbox':
>                     label['_for'] = None
>                     label.insert(0, controls)
>                     label.insert(1, ' ')
>                     _controls = DIV(DIV(label, _class="checkbox"),
>                                     _class="%s %s" % (offset_class, 
> col_class))
>                     label = ''
>                 elif isinstance(controls, (SELECT, TEXTAREA)):
>                     controls.add_class('form-control')
>                     controls.add_class(input_class)
>
>             elif isinstance(controls, SPAN):
>                 _controls = P(controls.components,
>                               _class="form-control-static %s" % col_class)
>             elif isinstance(controls, UL):
>                 for e in controls.elements("input"):
>                     e.add_class('form-control')
>             if isinstance(label, LABEL):
>                 label['_class'] = add_class(label.get('_class'), '%s %s' % 
> (control_label, label_col_class))
>
>             parent.append(DIV(label, _controls, _help, _class='row', _id=id))
>         return DIV(parent, _class='form-group')
>     return _inner
>
>

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