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

Map the cleaned data back from ids for access from the json field

parent c5e21658
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ from wagtail.wagtailforms.models import AbstractFormSubmission
from opentech.apply.stream_forms.models import AbstractStreamForm
from .blocks import CustomFormFieldsBlock, REQUIRED_BLOCK_NAMES
from .blocks import CustomFormFieldsBlock, MustIncludeFieldBlock, REQUIRED_BLOCK_NAMES
from .forms import WorkflowFormAdminForm
from .workflow import SingleStage, DoubleStage
......@@ -60,9 +60,15 @@ class FundType(AbstractStreamForm):
return ApplicationSubmission
def process_form_submission(self, form):
# Handle passing to JSONField
cleaned_data = form.cleaned_data
for field in self.get_defined_fields():
# Update the ids which are unique to use the unique name
if isinstance(field.block, MustIncludeFieldBlock):
response = cleaned_data.pop(field.id)
cleaned_data[field.block.name] = response
return self.get_submission_class().objects.create(
form_data=form.cleaned_data,
form_data=cleaned_data,
page=self,
)
......
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