Skip to content

Instantly share code, notes, and snippets.

@mficzel
Last active May 24, 2019 13:48
Show Gist options
  • Save mficzel/266291d3bfd1a4d382c7e13627c68554 to your computer and use it in GitHub Desktop.
Save mficzel/266291d3bfd1a4d382c7e13627c68554 to your computer and use it in GitHub Desktop.
Idea: Neos.Fusion.Forms
//
// the form component creates a formDescription object and adds it to context `form`
//
prototype(Neos.Fusion.Form:Form) < prototype(Neos.Fusion.Forms:FormComponent) {
renderer = afx`
<form action={form.action}>
<div style="display: none">
<Neos.Fusion:Loop items={form.hiddenFields} itemName="hiddenField">
<input type="hidden" name={hiddenField.name} value={hiddenField.value} />
</Neos.Fusion:Loop>
</div>
{props.content}
</form>
`
}
//
// field components create a fieldDescription object and add it to the context as `field`
// if a `form` is in the context the fieldDescription is registered there aswell
//
prototype(Neos.Fusion.Form:Textfield) < prototype(Neos.Fusion.Forms:FormFieldComponent) {
renderer = afx`
<input
type="text"
name={field.name}
value={field.value}
class={field.hasErrors ? props.errorClass : ''}
/>
`
}
//
// Fusion forms shall be used like in this example
//
// Primary usecase will be backend modules but offcourse this can be used
// in site-fusion aswell
//
renderer = afx`
<Neos.Fusion.Form:Form
name="example"
property={example}
action="update"
>
<Neos.Fusion.Form:Textfield property="foo" />
<Neos.Fusion.Form:Textfield property="bar" />
<Neos.Fusion.Form:Submit />
</Neos.Fusion.Form:Form>
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment