jazzband / django-floppyforms

Full control of form rendering in the templates.
http://django-floppyforms.readthedocs.org/
Other
837 stars 148 forks source link

Custom radioselect required attrs Widget or rendered? #197

Closed jonaqp closed 4 years ago

jonaqp commented 6 years ago

from floppyforms import RadioSelect

custom

class CustomClearableRadioSelectOne(RadioSelect):
     template_name = 'themes/widgets/clearable_radio1.html'

template

<ul>{% for group_name, choices in optgroups %}{% for choice in choices %}
<li><label for="{{ attrs.id }}_{{ forloop.counter }}">
<input type="radio" id="{{ attrs.id }}_{{ forloop.counter }}" value="{{ choice.0 }}" name="{{ name }}"{% if required %} required{% endif %}{% if choice.0 in value %} checked{% endif %}> {{ choice.1 }}</label></li>
{% endfor %}{% endfor %}</ul>

forms

class UserForm(forms.ModelForm):
    document_choice = core_constants.TRIBUTE_PERSON_OPTIONS
    document_type = forms.ChoiceField(
        label="document type", widget=CustomClearableRadioSelectOne, choices=document_choice, required=True)

html

<div class="form-group">
{{ form.document_type.label_tag }}
{{ form.document_type }}
</div>

here the errors. (https://ibb.co/euhfU5)

Something that happened? I would like to change to create in this way. Any one a help or is it a bug?

(https://ibb.co/kAG795)

thanks

rtpg commented 4 years ago

the renderer error is from using pre-1.8.0. That is fixed now