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:


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
-  Make sure the ordering of fields in the rendered html stays the
   same (reorder fields in the individual \*/ instead)

Some special considerations for textareas might be needed, get in
touch with cwebber concerning this part.

Change History (12)

comment:1 by Christopher Allan Webber, 13 years ago

Owner: set to Caleb Davis

comment:1 by Caleb Davis, 13 years ago

What are the special considerations for textareas?

comment:2 by Christopher Allan Webber, 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 Caleb Davis, 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

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

comment:4 by Christopher Allan Webber, 13 years ago


` <>`_

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 Caleb Davis, 13 years ago

Status: NewFeedback
Okay, I think this is what you mean:

[\ :sub:`cfdv/mediagoblin/cfdvs-mediagoblin/commits/f446\_use\_render\_divs\_once\_per\_form](`\ cfdv/mediagoblin/cfdvs-mediagoblin/commits/f446\_use\_render\_divs\_once\_per\_form)

review requested!

comment:6 by Elrond, 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 Caleb Davis, 13 years ago

`\_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 Caleb Davis, 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 Caleb Davis, 13 years ago

ok, using render\_divs(form) for the comments in media.html now:

[\ :sub:`cfdv/mediagoblin/cfdvs-mediagoblin/commit/d9204d3a3dd91f63fd43345415ebeb6fc02cc1c8](`\ cfdv/mediagoblin/cfdvs-mediagoblin/commit/d9204d3a3dd91f63fd43345415ebeb6fc02cc1c8)

comment:10 by Christopher Allan Webber, 13 years ago

Milestone: 0.0.5
Status: FeedbackClosed

comment:11 by Will Kahn-Greene, 12 years ago

The original url for this bug was .

Note: See TracTickets for help on using tickets.