Add custom validation support to all fields except relationships
This commit is contained in:
parent
b75614eca9
commit
ce29f27c89
|
@ -6,6 +6,7 @@
|
|||
export let field
|
||||
export let label
|
||||
export let disabled = false
|
||||
export let validation
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
|
@ -35,6 +36,7 @@
|
|||
{label}
|
||||
{field}
|
||||
{disabled}
|
||||
{validation}
|
||||
type="attachment"
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
|
@ -44,6 +46,7 @@
|
|||
<CoreDropzone
|
||||
value={$fieldState.value}
|
||||
disabled={$fieldState.disabled}
|
||||
error={$fieldState.error}
|
||||
on:change={e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
}}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
export let label
|
||||
export let text
|
||||
export let disabled = false
|
||||
export let validation
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
|
@ -15,6 +16,7 @@
|
|||
{label}
|
||||
{field}
|
||||
{disabled}
|
||||
{validation}
|
||||
type="boolean"
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
|
|
|
@ -7,12 +7,21 @@
|
|||
export let placeholder
|
||||
export let disabled = false
|
||||
export let enableTime = false
|
||||
export let validation
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
</script>
|
||||
|
||||
<Field {label} {field} {disabled} type="datetime" bind:fieldState bind:fieldApi>
|
||||
<Field
|
||||
{label}
|
||||
{field}
|
||||
{disabled}
|
||||
{validation}
|
||||
type="datetime"
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
>
|
||||
{#if fieldState}
|
||||
<CoreDatePicker
|
||||
value={$fieldState.value}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
export let defaultValue
|
||||
export let type
|
||||
export let disabled = false
|
||||
export let validation
|
||||
|
||||
// Get contexts
|
||||
const formContext = getContext("form")
|
||||
|
@ -21,7 +22,12 @@
|
|||
// Register field with form
|
||||
const formApi = formContext?.formApi
|
||||
const labelPosition = fieldGroupContext?.labelPosition || "above"
|
||||
const formField = formApi?.registerField(field, defaultValue, disabled)
|
||||
const formField = formApi?.registerField(
|
||||
field,
|
||||
defaultValue,
|
||||
disabled,
|
||||
validation
|
||||
)
|
||||
|
||||
// Expose field properties to parent component
|
||||
fieldState = formField?.fieldState
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
export let label
|
||||
export let placeholder
|
||||
export let disabled = false
|
||||
export let validation
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
|
@ -15,6 +16,7 @@
|
|||
{label}
|
||||
{field}
|
||||
{disabled}
|
||||
{validation}
|
||||
type="longform"
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
export let placeholder
|
||||
export let disabled = false
|
||||
export let optionsType = "select"
|
||||
export let validation
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
|
@ -17,6 +18,7 @@
|
|||
{field}
|
||||
{label}
|
||||
{disabled}
|
||||
{validation}
|
||||
type="options"
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
export let label
|
||||
export let placeholder
|
||||
export let disabled = false
|
||||
export let validation
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
|
@ -64,6 +65,7 @@
|
|||
{label}
|
||||
{field}
|
||||
{disabled}
|
||||
{validation}
|
||||
type="link"
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
export let placeholder
|
||||
export let type = "text"
|
||||
export let disabled = false
|
||||
export let validation
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
|
@ -16,6 +17,7 @@
|
|||
{label}
|
||||
{field}
|
||||
{disabled}
|
||||
{validation}
|
||||
type={type === "number" ? "number" : "string"}
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
|
|
Loading…
Reference in New Issue