Skip to content

Commit

Permalink
confirm field exists in form before setting
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Feb 5, 2025
1 parent 180ad51 commit d7ced99
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions edc_pharmacy/forms/prescription/rx_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ def get_last_weight():
class RxForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["randomizer_name"] = forms.ChoiceField(
label="Randomizer name",
choices=site_randomizers.get_as_choices(),
required=False,
)
if self.fields.get("randomizer_name"):
self.fields["randomizer_name"] = forms.ChoiceField(
label="Randomizer name",
choices=site_randomizers.get_as_choices(),
required=False,
)

subject_identifier = forms.CharField(
label="Subject Identifier",
Expand Down

0 comments on commit d7ced99

Please sign in to comment.