On Thu, Jun 23, 2011 at 10:11 AM, Idan Gazit <i...@gazit.me> wrote:
>
>
> On Thursday, June 23, 2011 4:06:05 PM UTC+3, dmoisset wrote:
>>
>> What is the "significant wart" ?
>
> The formconfig tag is a little bit "magical"; there's no other example in
> the template langauge of something explicitly affecting state in the same
> fashion. Even things like the "with" tag are self-bounding.
> Granted, formconfig is scoped to the form block, but stil. Feels a little
> bit dirty to me.

Maybe bikeshedding, but have you considered storing the configuration
on automatically created variables, and then setting those with a {%
with %} tag?

Automatically created variables is not a new concept ({% for %}
creates a "forloop" variable). Let me translate your previous example
to this idea to see what you think. I chose names rather arbitrarily,
probably they can be better thought out:

{% formconfig widget widgets.Textarea for "comment" %}

translates to...

{% with formconfig_widget_comment=widgets.Textarea %}
... the rest of the form here
{% endwith %}

And,

{% formconfig widget widgets.Textarea for "comment" %}

translates to...

{% with formconfig_row="forms/rows/ul.html" %}
... the rest of the form here
{% endwith %}

And,

  {% formconfig row using "forms/rows/p.html" %}
  {% formrow field1 %}
  {% formrow field2 %}
  {% formconfig row using "myrows/fancydiv.html" %}
  {% formrow field3 %}

...translates to...

{% with formconfig_row="forms/rows/p.html" %}
  {% formrow field1 %}
  {% formrow field2 %}
{% endwith %}
{% with formconfig_row="myrows/fancydiv.html" %}
  {% formrow field3 %}
{% endwith %}

Additionally, in the example above, it is easy to set a row renderer
for a single row and then go back to the default without having to
specifying explicitly:

  {% formrow field1 %}
  {% formrow field2 %}
{% with formconfig_row="myrows/fancydiv.html" %}
  {% formrow field3 %}
{% endwith %}
  {% formrow field4 %}

Actually, in my ideal world, instead of names with underscores, I'd
like to have formconfig.row and formconfig.widgets.fieldname, but that
would require adding some extra support for dotted vars to {% with %}
that might be dangerous

As an additional "I want a pony" feature, maybe if you are allowed to
define formconfig vars *outside* the form, and getting the form to
inherit it, you can make settings that span more than one form (and
still being explicitly scoped by a {% with %} tag)

What do you think?

Regards,
   D.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to