I have a form like this:
RANGE_CHOICES = (
('last', 'Last Year'),
('this', 'This Year'),
('next', 'Next Year'),
)
class MonthlyTotalsForm(forms.Form):
range = forms.ChoiceField(choices=RANGE_CHOICES, initial='this')
It's displayed in the template like this:
{{ form.range }}
In some situations I don't want to show the 'Next Year' option. Is it possible to remove this option in the view where the form is created?
Click on the “Add-ons” puzzle piece icon. Select “Choice Eliminator 2” and then “Configure.” In the mini box to the right, click on your first question. Then select “Eliminate Choices.” It will take a few seconds to process.
Dynamic Fields Add-on for Google Forms™ populates values of selection fields. Questions of type Multiple-choice, Drop-down, Checkbox or Grid can be updated by data from Sheets, Contacts or Groups. Create in Google Forms™ dynamic choice boxes.
Create a new Google Form and then click on the three vertical dots to the right-hand side of the 'Send' button. In here click on 'Add-ons' and in the search apps box type in Choice Eliminator. There are two options to pick from. Choice Eliminator 2 and Choice Eliminator Lite.
Open your form in Google Forms > Click Responses > Click Individual > Click previous or next icon to view the response you want to delete > Click delete icon > Confirmation popup will be displayed.
class MonthlyTotalsForm(forms.Form):
range = forms.ChoiceField(choices=RANGE_CHOICES, initial='this')
def __init__(self, *args, **kwargs):
no_next_year = kwargs.pop('no_next_year', False)
super(MonthlyTotalsForm, self).__init__(*args, **kwargs)
if no_next_year:
self.fields['range'].choices = RANGE_CHOICES[:-1]
#views.py
MonthlyTotalsForm(request.POST, no_next_year=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With