Skip to content

Commit

Permalink
fix(forms): set choices of Select2 widget
Browse files Browse the repository at this point in the history
The Select2 widgets needs the choices to be set to show the existing
value.
  • Loading branch information
b1rger committed Aug 26, 2024
1 parent 20644b8 commit 5add6fa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apis_bibsonomy/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class Meta:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper(self)
if "instance" in kwargs:
self.fields["bibs_url"].widget.choices = [
(self.initial.get("bibs_url"), self.instance.bibtexjson.get("title"))
]
self.helper.layout = Layout(
Row(
Div("bibs_url", css_class="col"),
Expand Down

0 comments on commit 5add6fa

Please sign in to comment.