Skip to content
Snippets Groups Projects
Commit 340c12f1 authored by Fredrik Jonsson's avatar Fredrik Jonsson
Browse files

Easier to read error message for fields that can only be included once.

parent c7b95fa7
No related branches found
No related tags found
No related merge requests found
......@@ -79,7 +79,7 @@ class CustomFormFieldsBlock(StreamBlock):
if duplicates:
all_errors.append(
'You have duplicates of the following non duplicate fields: {}'.format(', '.join(prettify_names(duplicates)))
'The following fields must be included only once: {}'.format(', '.join(prettify_names(duplicates)))
)
for i, block_name in enumerate(block_types):
if block_name in duplicates:
......@@ -117,6 +117,7 @@ class SingleIncludeStatic(StaticBlock):
"""Helper block which displays additional information about the must include block and
helps display the error in a noticeable way.
"""
def __init__(self, *args, description='', **kwargs):
self.description = description
super().__init__(*args, **kwargs)
......@@ -155,6 +156,7 @@ class MustIncludeFieldBlock(SingleIncludeMixin, FormFieldBlock):
"""Any block inheriting from this will need to be included in the application forms
This data will also be available to query on the submission object
"""
def get_field_kwargs(self, struct_value):
kwargs = super().get_field_kwargs(struct_value)
kwargs['required'] = True
......
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