Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom radioselect required attrs Widget or rendered? #197

Closed
jonaqp opened this issue Aug 21, 2017 · 1 comment
Closed

Custom radioselect required attrs Widget or rendered? #197

jonaqp opened this issue Aug 21, 2017 · 1 comment

Comments

@jonaqp
Copy link

jonaqp commented Aug 21, 2017

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

@jonaqp jonaqp changed the title Csutom radioselect required attrs Widget or rendered? Custom radioselect required attrs Widget or rendered? Aug 21, 2017
@rtpg
Copy link
Contributor

rtpg commented May 19, 2020

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

@rtpg rtpg closed this as completed May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants