Browse Source

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

gh-pages
Andrew Kingston 5 years ago
parent
commit
88354073aa
  1. 6
      packages/standard-components/manifest.json
  2. 21
      packages/standard-components/src/forms/InnerForm.svelte

6
packages/standard-components/manifest.json

@ -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"
} }
] ]
}, },

21
packages/standard-components/src/forms/InnerForm.svelte

@ -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 },
] ]
</script>
<Provider // Create data context to provide
{actions} $: dataContext = {
data={{ ...initialValues,
...$values, ...$values,
valid,
currentStep: $currentStep, // These static values are prefixed to avoid clashes with actual columns
currentStepValid: $currentStepValid, __valid: valid,
}} __currentStep: $currentStep,
> __currentStepValid: $currentStepValid,
}
</script>
<Provider {actions} data={dataContext}>
<div use:styleable={$component.styles}> <div use:styleable={$component.styles}>
<slot /> <slot />
</div> </div>

Loading…
Cancel
Save