Skip to content

Commit 0f490f7

Browse files
authored
Merge pull request #6 from typecode/field-choices-fix
Field choices fix
2 parents e7b082c + 4f31deb commit 0f490f7

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

wagtail_advanced_form_builder/forms/advanced_form_builder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ def create_checkbox_field(self, field, options):
7272

7373

7474
def create_radio_field(self, field, options):
75-
7675
options['choices'] = list(map(
7776
lambda x: (x.strip(), x.strip()),
78-
field.choices
77+
map(lambda x: x['value'] if type(x) is dict else x, field.choices)
7978
))
8079

8180
if field.display_side_by_side:
@@ -87,7 +86,7 @@ def create_radio_field(self, field, options):
8786
def create_multiselect_field(self, field, options):
8887
options['choices'] = list(map(
8988
lambda x: (x.strip(), x.strip()),
90-
field.choices
89+
map(lambda x: x['value'] if type(x) is dict else x, field.choices)
9190
))
9291
return forms.MultipleChoiceField(**options)
9392

wagtail_advanced_form_builder/forms/widgets/checkbox_input_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class CheckboxInput(DjangoCheckboxInput):
55

6-
def __init__(self, display_checkbox_label=False, *args, **kwargs):
6+
def __init__(self, display_checkbox_label=True, *args, **kwargs):
77
super().__init__(*args, **kwargs)
88
self.display_checkbox_label = display_checkbox_label
99

wagtail_advanced_form_builder/templates/wagtail_advanced_form_builder/fields/checkbox_field.html

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
class="waf--field-container {% if field.errors %}waf--field-container--error{% endif %}"
33
data-waf-field
44
>
5-
<div class="">
5+
<div class="waf--checkbox-container">
6+
{{ field }}
67
{% if field.field.widget.display_checkbox_label %}
7-
{% include "wagtail_advanced_form_builder/field_helpers/field_label.html" %}
8+
<label class="waf--field-label-choice" for="{{ field.id_for_label }}">
9+
{{ field.label }}
10+
</label>
811
{% endif %}
9-
<div class="waf--checkbox-container">
10-
{{ field }}
11-
<label class="waf--field-label-choice" for="{{ field.id_for_label }}">
12-
{% if field.help_text %}
13-
{% include "wagtail_advanced_form_builder/field_helpers/field_help_text.html" %}
14-
{% endif %}
15-
</label>
16-
</div>
1712
</div>
13+
{% if field.help_text %}
14+
{% include "wagtail_advanced_form_builder/field_helpers/field_help_text.html" %}
15+
{% endif %}
1816
{% include "wagtail_advanced_form_builder/field_helpers/field_error.html" %}
1917
</div>

0 commit comments

Comments
 (0)