Make form step number dynamic
This commit is contained in:
parent
347a0d1d0f
commit
9f30599ec1
|
@ -23,13 +23,14 @@
|
|||
// Register field with form
|
||||
const formApi = formContext?.formApi
|
||||
const labelPos = fieldGroupContext?.labelPosition || "above"
|
||||
$: formStep = formStepContext ? $formStepContext || 1 : 1
|
||||
$: formField = formApi?.registerField(
|
||||
field,
|
||||
type,
|
||||
defaultValue,
|
||||
disabled,
|
||||
validation,
|
||||
formStepContext || 1
|
||||
formStep
|
||||
)
|
||||
|
||||
// Focus label when editing
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<script>
|
||||
import { getContext, setContext } from "svelte"
|
||||
import { writable } from "svelte/store"
|
||||
import Placeholder from "../Placeholder.svelte"
|
||||
|
||||
export let step = 1
|
||||
|
@ -9,7 +10,9 @@
|
|||
const formContext = getContext("form")
|
||||
|
||||
// Set form step context so fields know what step they are within
|
||||
setContext("form-step", step || 1)
|
||||
const stepStore = writable(step || 1)
|
||||
$: stepStore.set(step || 1)
|
||||
setContext("form-step", stepStore)
|
||||
|
||||
$: formState = formContext?.formState
|
||||
$: currentStep = $formState?.currentStep
|
||||
|
|
Loading…
Reference in New Issue