Hi,

to solve this problem, I have written a class that generates Bootstrap form 
HTML based on the form object.

Turned out to be very useful and reliable.

HTH,
vogan

On Monday, 23 February 2015 21:50:00 UTC+1, Maciej Wawrzyńczuk wrote:
>
> Hi,
>
> I found using forms with bootstrap css library little bit tricky. 
> Bootstrap needs code like that:
> <form>
>   <div class="blah blah">
>     <label...
>     <imput...
>   </div>
> ...
> </form>
>
> But render_css does:
> <label...
> <input...
> <label...
> <input...
>
> With 'pre' attribute you can insert something between label and input 
> tags. I would be useful to include some code between label. 
>
> I modified render_css in derived class:
>
> class bootstrap_form(form.Form):
>     def render_bootstrap(self):
>         from web import net
>         out = []
>         out.append(self.rendernote(self.note))
>         for i in self.inputs:
>             out.append('<div class="form-group">')
>             if not i.is_hidden():
>                 out.append('<label for="%s">%s</label>' % (i.id, 
> net.websafe(i.description)))
>             out.append(i.pre)
>             out.append(i.render())
>             out.append(self.rendernote(i.note))
>             out.append(i.post)
>             out.append('</div>')
>             out.append('\n')
>         return ''.join(out) 
>
>
> It works for me but I think it could be done better. What do you think?
>
> Regards, M.
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to