[html-formfu] Bootstrap forms again...
Nigel Metheringham
nigel at dotdot.it
Wed May 29 16:35:14 GMT 2013
Like various other people, I hit the difficulty lining up FormFu's form
generation and Bootstrap.
I did get it working OK with tt based HTML generation, and actually very
minor changes - although I have effectively hardwired to horizontal
forms - see http://twitter.github.io/bootstrap/base-css.html#forms - and
inline checkboxes.
However I think if the class addition was removed from the form tag, the
horizontal forms would revert to "normal" even with the additional label
markup, and the inline checkboxes are similarly a case of just change an
attribute.
So, the only changes from the default form tt files were:-
- start_form - tweaked the classes on the form tag
possibly doable with just attributes
- textarea_tag - wrapped an extra div around for use with
ckeditor (unrelated to bootstrap really)
- field - the main label/control-group changes for bootstrap
- checkboxgroup_tag - rework for inline checkboxes
I've not spent a batch of time profiling speed with this - its good
enough for my use. The tt could be made faster by reusing the tt object
I already have in place for the app - in fact I suspect I could probably
do this by changing the
[% form.render %]
in those templates to something that does form.render_data and then just
calls PROCESS on the templates (would then get all the templates into my
cache too).
In terms of just making a new bootstrap renderer within the classes, it
should be easily doable by having it use the string renderer everywhere
except the 4 places mentioned above.
The form definitions have also changed slightly - but only in that I
have added some class attributes to some elements (mainly to force them
wider - attributes => {class => 'span6'} - or to make the form buttons
prettier.
Nigel.
--
[ Nigel Metheringham ------------------------------ nigel at dotdot.it ]
[ Ellipsis Intangible Technologies ]
More information about the HTML-FormFu
mailing list