Rendering a Neos.Form.Builder:Form in a content collection

Hello,

I switched from Neos.Form to Neos.Form.Builder:Form in order to do some fusion magic with my form. Everything worked out well, the syntax and variables were almost identical, but I see that I can’t render my fusionified form as a content element like I did with the yaml-defined form.

For this reason I have created a new node type with a simple select-box which allows you to choose the form you want to render by its fusion prototype name ie:

properties:
  targetForm:
    type: string
    defaultValue: ''
    ui:
      reloadIfChanged: TRUE
      label: 'Pick a form'
      inspector:
        group: 'form'
        editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor'
        editorOptions:
          allowEmpty: TRUE
          values:
            Vendor.Site:ContactForm:
              label: 'Contact Form'

Fusion:

prototype(Vendor.Site:FormReference) < prototype(Neos.Neos:Content) {
    form = Neos.Fusion:Renderer {
        @if.isSet = ${q(node).property('targetForm')}
        type = ${q(node).property('targetForm')}
    }
}

Which is stupid, overkill and non-dynamic.

My question is, what’s the way to go with the same logic as the default ‘Form’ content element ?
It would be even better if I could extend the default to also include fusion-defined forms.

@bwaidelich I would be glad to hear your advice / solution on this.

Thanks !

Hi,

I think your solution is not bad actually.
To automate this you could use create a dedicated data source (like we did in the former implementation) . That could fetch all Form prototypes automagically…
Could be a nice candidate for your first Pull Request :slight_smile:

Thanks Bastian,

I had taken a look to the Form declaration before, but I couldn’t understand how the datasource thing works, I’ll take a second look today and keep you posted.

Ok, I get the idea of the datasource and how the form select-box gets populated for the Neos:Form node type.

However, I don’t understand how it’s rendered. The data source looks for the defined forms and returns identifier => label pairs to populate the select-box options, but then what ? Once the desired form is selected and the identifier string gets saved, how does the actual form gets rendered ? I don’t see any fusion taking the identifier (which is just a string) and process it. The only thing I can find is this in the NodeTypes Root.fusion :

# Form TS Object
prototype(Neos.NodeTypes:Form) {
	presetName = 'default'
	overrideConfiguration = Neos.Fusion:RawArray
	@cache {
		mode = 'uncached'
		context {
			1 = 'node'
			2 = 'documentNode'
		}
	}
} 

Besides, the yaml forms data are parsed in PHP, but in the case of fusion … well if I understand it correctly fusion comes after PHP and it’s not supposed to be parsed in PHP, am I right ? If this is so, getting the list of fusion prototypes can be only done through fusion. Meaning, we can’t really use the data source approach. Is this correct, or am I missing something ?