Can you please open a ticket about this so it does not get lost? We need to
port welcome to bootstrap 3 asap.
On Thursday, 12 December 2013 12:08:15 UTC-6, Annet wrote:
>
> Some field definitions in my models have comments, which in a Bootstrap
> form are
> being displayed in a help-block.
>
> The problem is that this help-block
>
> <span class="help-block">my comment</span>
>
> is added to every form field, resulting in 20 px of extra padding between
> form fields, margin-bottom: 10px
> and margin-bottom: 5px. Is there a way to make adding a help-block
> conditional?
>
> So far I made the following adjustments to a custom formstyle function:
>
> def bootstrap3(form, fields):
> form.add_class('form-horizontal')
> parent = FIELDSET()
> for id, label, controls, help in fields:
> # wrappers
> _help = SPAN(help, _class='help-block')
> # embed _help into _controls
> _controls = DIV(controls, _help, _class='controls col-sm-8')
> # submit unflag by default
> _submit = False
>
> if isinstance(controls, INPUT):
> controls.add_class('form-control')
> if controls['_type'] == 'submit':
> # flag submit button
> _submit = True
> controls['_class'] = 'btn btn-primary'
> if controls['_type'] == 'file':
> controls['_class'] = 'input-file'
>
> # For password fields, which are wrapped in a CAT object.
> if isinstance(controls, CAT) and isinstance(controls[0], INPUT):
> controls[0].add_class('form-control')
>
> if isinstance(controls, SELECT):
> controls.add_class('form-control')
>
> if isinstance(controls, TEXTAREA):
> controls.add_class('form-control')
>
> if isinstance(label, LABEL):
> label['_class'] = 'col-sm-4 control-label'
>
> if _submit:
> # submit button has unwrapped label and controls, different
> class
> parent.append(DIV(label, controls, _class='col-sm-offset-4
> col-sm-8 form-actions', _id=id))
> # unflag submit (possible side effect)
> _submit = False
> else:
> # unwrapped label
> parent.append(DIV(label, _controls, _class='form-group',
> _id=id))
> return parent
>
>
>
> Kind regards,
>
> Annet
>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.