src/components/elements/form// src/components/elements/form/schema.yaml
$schema: http://json-schema.org/draft-07/schema#
$id: /elements/form
additionalProperties: false
required:
- children
- method
- action
properties:
attributes:
type: object
children:
type: string
format: html
classes:
type: array
items:
type: string
method:
type: string
default: post
enum:
- get
- post
- dialog
action:
type: string
format: uri-reference
// src/components/elements/form/mocks.yaml
$hidden: true
action: action
$variants:
- $name: default
method: get
children:
$render:
- $tpl: elements/form-element
$ref: elements/form-element#input
- $tpl: elements/form-element
$ref: elements/form-element#select
- $tpl: elements/options
$ref: elements/options#row
- $tpl: elements/form-element
$ref: elements/form-element#textarea
- $tpl: elements/form-element
$ref: elements/form-element#checkbox
- $tpl: elements/form-element
$ref: elements/form-element#submit
- $name: Auth
method: post
children:
$render:
- $tpl: elements/form-element
$ref: elements/form-element#input
label: E-Mail
- $tpl: elements/form-element
$ref: elements/form-element#input
label: Password
children:
type: password
id: form-element-password
type: password
- $tpl: elements/form-element
$ref: elements/form-element#submit
value: Submit
// src/components/elements/form/form.twig
<form{{ attributes }} method="{{ method|default('post') }}" action="{{ action }}" class="Form {{ classes|join(" ") }}">
{{ children }}
</form>
default mock data
action: action
method: get
children:
$render:
- $tpl: elements/form-element
$ref: elements/form-element#input
- $tpl: elements/form-element
$ref: elements/form-element#select
- $tpl: elements/options
$ref: elements/options#row
- $tpl: elements/form-element
$ref: elements/form-element#textarea
- $tpl: elements/form-element
$ref: elements/form-element#checkbox
- $tpl: elements/form-element
$ref: elements/form-element#submit
Auth mock data
action: action
method: post
children:
$render:
- $tpl: elements/form-element
$ref: elements/form-element#input
label: E-Mail
- $tpl: elements/form-element
$ref: elements/form-element#input
label: Password
children:
type: password
id: form-element-password
type: password
- $tpl: elements/form-element
$ref: elements/form-element#submit
value: Submit