@@ -211,13 +211,13 @@ def prepare_value(self, value):
211211
212212class LiaisonModelForm (BetterModelForm ):
213213 '''Specify fields which require a custom widget or that are not part of the model.
214- NOTE: from_groups and to_groups are marked as not required because select2 has
215- a problem with validating
216214 '''
217215 from_groups = forms .ModelMultipleChoiceField (queryset = Group .objects .all (),label = 'Groups' ,required = False )
216+ from_groups .widget .attrs ["class" ] = "select2-field"
218217 from_contact = forms .EmailField () # type: Union[forms.EmailField, SearchableEmailField]
219218 to_contacts = forms .CharField (label = "Contacts" , widget = forms .Textarea (attrs = {'rows' :'3' , }), strip = False )
220219 to_groups = forms .ModelMultipleChoiceField (queryset = Group .objects ,label = 'Groups' ,required = False )
220+ to_groups .widget .attrs ["class" ] = "select2-field"
221221 deadline = DatepickerDateField (date_format = "yyyy-mm-dd" , picker_settings = {"autoclose" : "1" }, label = 'Deadline' , required = True )
222222 related_to = SearchableLiaisonStatementsField (label = 'Related Liaison Statement' , required = False )
223223 submitted_date = DatepickerDateField (date_format = "yyyy-mm-dd" , picker_settings = {"autoclose" : "1" }, label = 'Submission date' , required = True , initial = datetime .date .today ())
@@ -247,8 +247,8 @@ def __init__(self, user, *args, **kwargs):
247247 self .person = get_person_for_user (user )
248248 self .is_new = not self .instance .pk
249249
250- self .fields ["from_groups" ].widget .attrs ["placeholder" ] = "Type in name to search for group"
251- self .fields ["to_groups" ].widget .attrs ["placeholder" ] = "Type in name to search for group"
250+ self .fields ["from_groups" ].widget .attrs ["data- placeholder" ] = "Type in name to search for group"
251+ self .fields ["to_groups" ].widget .attrs ["data- placeholder" ] = "Type in name to search for group"
252252 self .fields ["to_contacts" ].label = 'Contacts'
253253 self .fields ["other_identifiers" ].widget .attrs ["rows" ] = 2
254254
@@ -449,7 +449,7 @@ def set_from_fields(self):
449449 else :
450450 queryset = Group .objects .filter (type = "sdo" , state = "active" , role__person = self .person , role__name__in = ("liaiman" , "auth" )).distinct ().order_by ('name' )
451451 self .fields ['from_contact' ].initial = self .person .role_set .filter (group = queryset [0 ]).first ().email .address
452- self .fields ['from_contact' ].widget .attrs ['readonly ' ] = True
452+ self .fields ['from_contact' ].widget .attrs ['disabled ' ] = True
453453 self .fields ['from_groups' ].queryset = queryset
454454 self .fields ['from_groups' ].widget .submitter = str (self .person )
455455
@@ -504,7 +504,7 @@ def set_from_fields(self):
504504 else :
505505 email = self .person .email_address ()
506506 self .fields ['from_contact' ].initial = email
507- self .fields ['from_contact' ].widget .attrs ['readonly ' ] = True
507+ self .fields ['from_contact' ].widget .attrs ['disabled ' ] = True
508508
509509 def set_to_fields (self ):
510510 '''Set to_groups and to_contacts options and initial value based on user
@@ -551,7 +551,7 @@ def set_from_fields(self):
551551 queryset = Group .objects .filter (type = "sdo" ).order_by ('name' )
552552 else :
553553 queryset = Group .objects .filter (type = "sdo" , role__person = self .person , role__name__in = ("liaiman" , "auth" )).distinct ().order_by ('name' )
554- self .fields ['from_contact' ].widget .attrs ['readonly ' ] = True
554+ self .fields ['from_contact' ].widget .attrs ['disabled ' ] = True
555555 self .fields ['from_groups' ].queryset = queryset
556556
557557 def set_to_fields (self ):
@@ -571,5 +571,4 @@ def set_to_fields(self):
571571
572572
573573class EditAttachmentForm (forms .Form ):
574- title = forms .CharField (max_length = 255 )
575-
574+ title = forms .CharField (max_length = 255 )
0 commit comments