jazzband/django-floppyforms

Custom radioselect required attrs Widget or rendered?

jonaqp opened this issue · 1 comments

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

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