custom attrs passed to a widget are ignored when using RadioSelect
Closed this issue · 4 comments
When using a standard RadioSelect widget with custom attrs like:
widget = forms.RadioSelect(attrs = {'data-control-jqgridselector': self.add_prefix(fname)})
these attrs are being ignored.
I believe it's due to the way choice fields are handled in field_choices.html template - this code takes no custom attributes into account.
sorry I'm not fluent with using git, so won't do pull request etc.
here's the solution just put it before closing ">" of the input tag in field_choices.html
{% for attr,vall in field.field.widget.attrs.items %}{{ attr }}="{{ vall }}"{% endfor %}
Thank you!
I'm sorry, there was a mistake in my code! There's a space missing between closing "%}" of "for" statement and the {{ attr }}.
when there are more than 1 attributes, they're not separated with a space, thus they are not parser by browser!!
{% for attr,vall in field.field.widget.attrs.items %} {{ attr }}="{{ vall }}"{% endfor %}
sorry again for the misleading comment.
Ah, that's why my test didn't show any errors. I'll fix it.
Op 6 dec. 2012, om 10:36 heeft migajek notifications@github.com het volgende geschreven:
I'm sorry, there was a mistake in my code! There's a space missing between closing "%}" of "for" statement and the {{ attr }}.
when there are more than 1 attributes, they're not separated with a space, thus they are not parser by browser!!{% for attr,vall in field.field.widget.attrs.items %} {{ attr }}="{{ vall }}"{% endfor %}
—
Reply to this email directly or view it on GitHub.