Add missing initial form values to form context and prefix static values to avoid clashes with column names

This commit is contained in:
Andrew Kingston 2021-08-23 11:10:07 +01:00
parent 27be64a6fd
commit 88354073aa
2 changed files with 15 additions and 12 deletions

View File

@ -1739,15 +1739,15 @@
"values": [ "values": [
{ {
"label": "Valid", "label": "Valid",
"key": "valid" "key": "__valid"
}, },
{ {
"label": "Current Step", "label": "Current Step",
"key": "currentStep" "key": "__currentStep"
}, },
{ {
"label": "Current Step Valid", "label": "Current Step Valid",
"key": "currentStepValid" "key": "__currentStepValid"
} }
] ]
}, },

View File

@ -256,17 +256,20 @@
{ type: ActionTypes.ClearForm, callback: formApi.clear }, { type: ActionTypes.ClearForm, callback: formApi.clear },
{ type: ActionTypes.ChangeFormStep, callback: formApi.changeStep }, { type: ActionTypes.ChangeFormStep, callback: formApi.changeStep },
] ]
// Create data context to provide
$: dataContext = {
...initialValues,
...$values,
// These static values are prefixed to avoid clashes with actual columns
__valid: valid,
__currentStep: $currentStep,
__currentStepValid: $currentStepValid,
}
</script> </script>
<Provider <Provider {actions} data={dataContext}>
{actions}
data={{
...$values,
valid,
currentStep: $currentStep,
currentStepValid: $currentStepValid,
}}
>
<div use:styleable={$component.styles}> <div use:styleable={$component.styles}>
<slot /> <slot />
</div> </div>