Opened 15 years ago
Last modified 15 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 , 15 years ago
| Owner: | set to |
|---|
comment:1 by , 15 years ago
comment:2 by , 15 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 , 15 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 , 15 years ago
Hm.
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 , 15 years ago
| Status: | New → Feedback |
|---|
Okay, I think this is what you mean:
[https://gitorious.org/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 , 15 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 , 15 years ago
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 , 15 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 , 15 years ago
ok, using render_divs(form) for the comments in media.html now:
[https://gitorious.org/cfdv/mediagoblin/cfdvs-mediagoblin/commit/d9204d3a3dd91f63fd43345415ebeb6fc02cc1c8](https://gitorious.org/cfdv/mediagoblin/cfdvs-mediagoblin/commit/d9204d3a3dd91f63fd43345415ebeb6fc02cc1c8)
comment:11 by , 14 years ago
The original url for this bug was http://bugs.foocorp.net/issues/446 .

What are the special considerations for textareas?