Last active
May 24, 2019 13:48
-
-
Save mficzel/266291d3bfd1a4d382c7e13627c68554 to your computer and use it in GitHub Desktop.
Idea: Neos.Fusion.Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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> | |
` | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 : ''} | |
/> | |
` | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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