shivsharma07 / django-survey

Automatically exported from code.google.com/p/django-survey
0 stars 0 forks source link

label for="id_answer" isn't quite right #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Something isn't quite right, but I can't figure out where it is failing.

        <div>
<label for="id_answer">Company Name :</label>
 <span class="helptext">(this question is optional)</span> 
<input name="1_1-answer" id="id_1_1-answer" type="text">
        </div>

comes from

<label for="id_{{ bound_field.name }}">{{ bound_field.label }}
...
{{ bound_field }} 

"The id attribute values are generated by prepending id_ to the form field
names." 
http://www.djangoproject.com/documentation/forms/#configuring-html-label-tags

but in django?  (I have not svn up'ed yet - still running on something from
before the nfAdmin merge)

Original issue reported on code.google.com by cfkars...@gmail.com on 23 Jul 2008 at 6:58

GoogleCodeExporter commented 8 years ago
I am sorry but I do not see/understand the problem you are reporting. Could you 
be a
bit more specific ?
Thanks
--yml

Original comment by yann.ma...@gmail.com on 23 Jul 2008 at 8:40

GoogleCodeExporter commented 8 years ago
The 2 "string"s need to be the same in for="id_answer" and id="id_1_1-answer".

The general form is for="id", id="id", where "id" is unique for each question.  

Given that all the questions have the same key ("id_answer") I am guessing 
django's
{{ bound_field }} rendering is doing the right thing, and
for="id_{{bound_field.name}}" needs to do the same thing.  the way I read the 
docs I
quoted, that line should be doing the same thing, but it isn't. 

I am going to post this to dj-users list and see if anyone has any ideas.

Original comment by cfkars...@gmail.com on 23 Jul 2008 at 10:23

GoogleCodeExporter commented 8 years ago
"fixed"  (I don't understand why the old code didn't work, but I think I will 
let the
nfa dust settle)

carl@dv67:~/dj/lib/django-survey/survey$ svn diff templates/newforms/field.html 
Index: templates/newforms/field.html
===================================================================
--- templates/newforms/field.html   (revision 74)
+++ templates/newforms/field.html   (working copy)
@@ -1,6 +1,6 @@
 {% if bound_field.errors %}<p>{{ bound_field.errors }}</p>{% endif %}

-<label for="id_{{ bound_field.name }}">{{ bound_field.label }} :</label>
+{{ bound_field.label_tag }}

Original comment by cfkars...@gmail.com on 23 Jul 2008 at 11:09

GoogleCodeExporter commented 8 years ago
and nothing to do with this issue, but as long as we are looking at that code, 
I like
this better:

 svn diff templates/newforms/field.html 
Index: templates/newforms/field.html
===================================================================
--- templates/newforms/field.html   (revision 74)
+++ templates/newforms/field.html   (working copy)
@@ -1,7 +1,6 @@
 {% if bound_field.errors %}<p>{{ bound_field.errors }}</p>{% endif %}

-<label for="id_{{ bound_field.name }}">{{ bound_field.label }} :</label>
-{% if bound_field.field.required %}<span class="required"><sup> * 
</sup></span>{%
endif %}
+<span class="{{ bound_field.field.required|yesno:"required,optional"}}"> {{
bound_field.label_tag }} </span>
 {% if bound_field.help_text %} <span class="helptext">({{ bound_field.help_text
}})</span> {% endif %}
 {% if bound_field.form.question.get_image_url %}<img src="{{
bound_field.form.question.get_image_url }}"</img>{% endif %}
 {% if bound_field.form.choice.get_image_url %}<img src="{{
bound_field.form.choice.get_image_url }}"</img>{% endif %}

Original comment by cfkars...@gmail.com on 23 Jul 2008 at 11:24

GoogleCodeExporter commented 8 years ago
Fixed in r 87

Original comment by yann.ma...@gmail.com on 24 Jul 2008 at 10:56

GoogleCodeExporter commented 8 years ago

Original comment by yann.ma...@gmail.com on 24 Jul 2008 at 10:56