Skip to content
Snippets Groups Projects
Commit 48165a34 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

GH-996: Tidy up the formatting of the get_field_kwargs method - no func change

parent 21f4faf9
No related branches found
No related tags found
No related merge requests found
...@@ -37,9 +37,11 @@ class FormFieldBlock(StructBlock): ...@@ -37,9 +37,11 @@ class FormFieldBlock(StructBlock):
return self.widget return self.widget
def get_field_kwargs(self, struct_value): def get_field_kwargs(self, struct_value):
kwargs = {'label': struct_value['field_label'], kwargs = {
'help_text': struct_value['help_text'], 'label': struct_value['field_label'],
'required': struct_value.get('required', False)} 'help_text': struct_value['help_text'],
'required': struct_value.get('required', False)
}
if 'default_value' in struct_value: if 'default_value' in struct_value:
kwargs['initial'] = struct_value['default_value'] kwargs['initial'] = struct_value['default_value']
form_widget = self.get_widget(struct_value) form_widget = self.get_widget(struct_value)
...@@ -173,10 +175,11 @@ class RadioButtonsFieldBlock(OptionalFormFieldBlock): ...@@ -173,10 +175,11 @@ class RadioButtonsFieldBlock(OptionalFormFieldBlock):
icon = 'radio-empty' icon = 'radio-empty'
def get_field_kwargs(self, struct_value): def get_field_kwargs(self, struct_value):
kwargs = super(RadioButtonsFieldBlock, kwargs = super().get_field_kwargs(struct_value)
self).get_field_kwargs(struct_value) kwargs['choices'] = [
kwargs['choices'] = [(choice, choice) (choice, choice)
for choice in struct_value['choices']] for choice in struct_value['choices']
]
return kwargs return kwargs
...@@ -188,8 +191,7 @@ class DropdownFieldBlock(RadioButtonsFieldBlock): ...@@ -188,8 +191,7 @@ class DropdownFieldBlock(RadioButtonsFieldBlock):
icon = 'arrow-down-big' icon = 'arrow-down-big'
def get_field_kwargs(self, struct_value): def get_field_kwargs(self, struct_value):
kwargs = super(DropdownFieldBlock, kwargs = super().get_field_kwargs(struct_value)
self).get_field_kwargs(struct_value)
kwargs['choices'].insert(0, BLANK_CHOICE_DASH[0]) kwargs['choices'].insert(0, BLANK_CHOICE_DASH[0])
return kwargs return kwargs
...@@ -206,10 +208,11 @@ class CheckboxesFieldBlock(OptionalFormFieldBlock): ...@@ -206,10 +208,11 @@ class CheckboxesFieldBlock(OptionalFormFieldBlock):
template = 'stream_forms/render_list_field.html' template = 'stream_forms/render_list_field.html'
def get_field_kwargs(self, struct_value): def get_field_kwargs(self, struct_value):
kwargs = super(CheckboxesFieldBlock, kwargs = super().get_field_kwargs(struct_value)
self).get_field_kwargs(struct_value) kwargs['choices'] = [
kwargs['choices'] = [(choice, choice) (choice, choice)
for choice in struct_value['checkboxes']] for choice in struct_value['checkboxes']
]
return kwargs return kwargs
def get_searchable_content(self, value, data): def get_searchable_content(self, value, data):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment