Skip to content

Commit

Permalink
Merge pull request #6 from typecode/field-choices-fix
Browse files Browse the repository at this point in the history
Field choices fix
  • Loading branch information
fredevery authored Jun 2, 2023
2 parents e7b082c + 4f31deb commit 0f490f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
5 changes: 2 additions & 3 deletions wagtail_advanced_form_builder/forms/advanced_form_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ def create_checkbox_field(self, field, options):


def create_radio_field(self, field, options):

options['choices'] = list(map(
lambda x: (x.strip(), x.strip()),
field.choices
map(lambda x: x['value'] if type(x) is dict else x, field.choices)
))

if field.display_side_by_side:
Expand All @@ -87,7 +86,7 @@ def create_radio_field(self, field, options):
def create_multiselect_field(self, field, options):
options['choices'] = list(map(
lambda x: (x.strip(), x.strip()),
field.choices
map(lambda x: x['value'] if type(x) is dict else x, field.choices)
))
return forms.MultipleChoiceField(**options)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class CheckboxInput(DjangoCheckboxInput):

def __init__(self, display_checkbox_label=False, *args, **kwargs):
def __init__(self, display_checkbox_label=True, *args, **kwargs):
super().__init__(*args, **kwargs)
self.display_checkbox_label = display_checkbox_label

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
class="waf--field-container {% if field.errors %}waf--field-container--error{% endif %}"
data-waf-field
>
<div class="">
<div class="waf--checkbox-container">
{{ field }}
{% if field.field.widget.display_checkbox_label %}
{% include "wagtail_advanced_form_builder/field_helpers/field_label.html" %}
<label class="waf--field-label-choice" for="{{ field.id_for_label }}">
{{ field.label }}
</label>
{% endif %}
<div class="waf--checkbox-container">
{{ field }}
<label class="waf--field-label-choice" for="{{ field.id_for_label }}">
{% if field.help_text %}
{% include "wagtail_advanced_form_builder/field_helpers/field_help_text.html" %}
{% endif %}
</label>
</div>
</div>
{% if field.help_text %}
{% include "wagtail_advanced_form_builder/field_helpers/field_help_text.html" %}
{% endif %}
{% include "wagtail_advanced_form_builder/field_helpers/field_error.html" %}
</div>

0 comments on commit 0f490f7

Please sign in to comment.