fix: use ModelMultipleChoiceField for 'bethere' when hidden (#3894)
The select2-based fields do not behave well on the SubmissionForm when hidden=True. The ModelMultipleChoiceField is enough for this case.
This commit is contained in:
parent
8e48230115
commit
4e4569acc1
|
@ -11,6 +11,7 @@ from ietf.group.models import Group
|
|||
from ietf.meeting.forms import sessiondetailsformset_factory
|
||||
from ietf.meeting.models import ResourceAssociation, Constraint
|
||||
from ietf.person.fields import SearchablePersonsField
|
||||
from ietf.person.models import Person
|
||||
from ietf.utils.html import clean_text_field
|
||||
from ietf.utils import log
|
||||
|
||||
|
@ -154,10 +155,17 @@ class SessionForm(forms.Form):
|
|||
self.fields["resources"].choices = [(x.pk,x.desc) for x in ResourceAssociation.objects.filter(name__used=True).order_by('name__order') ]
|
||||
|
||||
if self.hidden:
|
||||
# replace all the widgets to start...
|
||||
for key in list(self.fields.keys()):
|
||||
self.fields[key].widget = forms.HiddenInput()
|
||||
# re-replace a couple special cases
|
||||
self.fields['resources'].widget = forms.MultipleHiddenInput()
|
||||
self.fields['timeranges'].widget = forms.MultipleHiddenInput()
|
||||
# and entirely replace bethere - no need to support searching if input is hidden
|
||||
self.fields['bethere'] = forms.ModelMultipleChoiceField(
|
||||
widget=forms.MultipleHiddenInput, required=False,
|
||||
queryset=Person.objects.all(),
|
||||
)
|
||||
|
||||
def wg_constraint_fields(self):
|
||||
"""Iterates over wg constraint fields
|
||||
|
|
|
@ -289,9 +289,8 @@ def confirm(request, acronym):
|
|||
return redirect('ietf.secr.sreq.views.main')
|
||||
|
||||
session_data = form.data.copy()
|
||||
if 'bethere' in session_data:
|
||||
person_id_list = [ id for id in form.data['bethere'].split(',') if id ]
|
||||
session_data['bethere'] = Person.objects.filter(pk__in=person_id_list)
|
||||
# use cleaned_data for the 'bethere' field so we get the Person instances
|
||||
session_data['bethere'] = form.cleaned_data['bethere'] if 'bethere' in form.cleaned_data else []
|
||||
if session_data.get('session_time_relation'):
|
||||
session_data['session_time_relation_display'] = dict(Constraint.TIME_RELATION_CHOICES)[session_data['session_time_relation']]
|
||||
if session_data.get('joint_for_session'):
|
||||
|
|
Loading…
Reference in a new issue