Opened 13 years ago
Last modified 13 years ago
#156 closed defect (FIXED)
Use wtforms.render_divs(form) again
Reported by: | Elrond | Owned by: | Caleb Davis |
---|---|---|---|
Priority: | minor | Milestone: | 0.0.5 |
Component: | programming | Keywords: | |
Cc: | Parent Tickets: |
Description
Due to some reasons, the call to render\_divs(form) was turned into individual calls to wtforms\_util.render\_field\_div(form.field). It is currently believed, that this is unnecessary. The idea is to - Use the normal whole form based render\_to\_multiple\_divs macro again - Make sure the ordering of fields in the rendered html stays the same (reorder fields in the individual \*/forms.py instead) Some special considerations for textareas might be needed, get in touch with cwebber concerning this part.
Change History (12)
comment:1 by , 13 years ago
Owner: | set to |
---|
comment:2 by , 13 years ago
Special consideration for textareas is that without the rows and cols attributes they aren't standards-compliant (in HTML4 at least... not sure about HTML5?). We could make a widget that wraps the textarea widget and adds this though..
comment:3 by , 13 years ago
hm, I'm struggling to pass (rows=8, cols=20) as \*\*kwargs all the way to the field rendering widget. The TextAreaField rendering widget already expects them, if I'm reading render\_textarea\_div correctly. The terrible hack I have now is something like, :: {# Generically render a field #} {% macro render_field_div(field) %} ... ... {% if field.type == "TextAreaField" %} <div class="form_field_input">{{ field(rows=8, cols=20) }}</div> {% else %} <div class="form_field_input">{{ field }}</div> {% endif %} I'm not stuck yet, so I'm putting these thoughts here mostly for myself. But if I'm missing something obvious, feel free to chime in.
comment:4 by , 13 years ago
Hm. `http://www.w3.org/TR/html-markup/textarea.html <http://www.w3.org/TR/html-markup/textarea.html>`_ It looks like rows and cols might not longer be required in html5. So maybe we can just drop the special-textarea-handling altogether, remove the old macro from wtforms.html, and close this? :)
comment:5 by , 13 years ago
Status: | New → Feedback |
---|
Okay, I think this is what you mean: [https://gitorious.org/\ :sub:`cfdv/mediagoblin/cfdvs-mediagoblin/commits/f446\_use\_render\_divs\_once\_per\_form](https://gitorious.org/`\ cfdv/mediagoblin/cfdvs-mediagoblin/commits/f446\_use\_render\_divs\_once\_per\_form) review requested!
comment:6 by , 13 years ago
``mediagoblin/user_pages/media.html`` also uses ``render_field_div``. Could you check, if it's easier to read, etc with ``render_divs(form)``?
comment:7 by , 13 years ago
`https://gitorious.org/mediagoblin/mediagoblin/blobs/master/mediagoblin/templates/mediagoblin/user\_pages/media.html#line58 <https://gitorious.org/mediagoblin/mediagoblin/blobs/master/mediagoblin/templates/mediagoblin/user_pages/media.html#line58>`_ Yeah, when I saw that one I left it alone because there is only one field in the form. In this case I don't think we win any extra points for using render\_divs(form)
comment:8 by , 13 years ago
I suppose we could change it anyway in case some day we have multiple fields in the comments form...I suppose we don't lose anything that way, and could help ourselves down the line.
comment:9 by , 13 years ago
ok, using render\_divs(form) for the comments in media.html now: [https://gitorious.org/\ :sub:`cfdv/mediagoblin/cfdvs-mediagoblin/commit/d9204d3a3dd91f63fd43345415ebeb6fc02cc1c8](https://gitorious.org/`\ cfdv/mediagoblin/cfdvs-mediagoblin/commit/d9204d3a3dd91f63fd43345415ebeb6fc02cc1c8)
comment:11 by , 13 years ago
The original url for this bug was http://bugs.foocorp.net/issues/446 .
Note:
See TracTickets
for help on using tickets.