This one is better for form.add_button() [see col_class_rest]
+uses smaller buttons [see btn-group-sm]


*    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()*
*        TODO: control-label-sm není defnovaná (jako control-label, ale bez 
posunu dolů*
*        """*
*        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)*
*            col_class_rest = "col-sm-%d" % (12 - col_label_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(DIV(controls, 
_class="btn-group-sm"),*
*                                        _class="%s %s" % (col_class_rest, 
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