@@ -189,22 +189,22 @@ def __init__(self, *args, initial=None, **kwargs):
189189 # if standardize these, we can simplify this code
190190
191191 # Convert extra_choices Array Field from model to CharField for form
192- if 'extra_choices' in self .initial and self .initial ['extra_choices' ]:
193- extra_choices = self .initial ['extra_choices' ]
192+ if extra_choices := self .initial .get ('extra_choices' , None ):
194193 if isinstance (extra_choices , str ):
195194 extra_choices = [extra_choices ]
196- choices = ""
195+ choices = []
197196 for choice in extra_choices :
198197 # Setup choices in Add Another use case
199198 if isinstance (choice , str ):
200199 choice_str = ":" .join (choice .replace ("'" , "" ).replace (" " , "" )[1 :- 1 ].split ("," ))
201- choices += choice_str + " \n "
200+ choices . append ( choice_str )
202201 # Setup choices in Edit use case
203202 elif isinstance (choice , list ):
204- choice_str = ":" .join (choice )
205- choices += choice_str + "\n "
203+ value = choice [0 ].replace (':' , '\\ :' )
204+ label = choice [1 ].replace (':' , '\\ :' )
205+ choices .append (f'{ value } :{ label } ' )
206206
207- self .initial ['extra_choices' ] = choices
207+ self .initial ['extra_choices' ] = ' \n ' . join ( choices )
208208
209209 def clean_extra_choices (self ):
210210 data = []
0 commit comments