[SOLVED] Form Finisher: Get Form as NodeType

I wrote a Form Finisher in PHP and it is working as intended (extending AbstractFinisher). The only problem I have is that I need the get the form itself (preferably as a Node) in the Finisher, because I need to query a specific property of that form.

Is this possible with the current Form Framework?

Hi Burak,

before using the fusion based form builder package, I transferred the form identifier in a hidden field to the finisher. I then used the CreateContentContextTrait to load the node again and access it’s properties.

Basically you build an array like this and then pass it to the form view helper:

    overrideConfiguration = Neos.Fusion:RawArray {
        renderables = Neos.Fusion:RawArray {
            0 = Neos.Fusion:RawArray {
                renderables = Neos.Fusion:RawArray {
                    1000 = Neos.Fusion:RawArray {
                        type = 'Neos.Form:HiddenField'
                        identifier = 'formNodeIdentifier'
                        defaultValue = ${node.identifier}
                    }
                }
            }
        }
    }

And in the finisher

    $formNodeIdentifier = $formRuntime->getFormState()->getFormValue('formNodeIdentifier');
    $contentContext = $this->createContentContext('live', []);
    $formNode = $contentContext->getNodeByIdentifier($formNodeIdentifier);
2 Likes

Thanks a lot for the answer, I got it working now with your solution. There may be some security concerns with that (taking the ID from another form and changing the HTML) but I think it is okay for now.

Thanks :slight_smile:

1 Like

I also had this issue and could solve it by using finishers instead of renderables like

        overrideConfiguration {
            finishers = Neos.Fusion:RawArray {
                0 = Neos.Fusion:RawArray {
                    options = Neos.Fusion:RawArray {
                        nodeTitle = ${node.properties.title}
                    }
                }
            }
       }

Then using $nodeTitle = $this->parseOption('nodeTitle'); you have the node property. Similar you can add the node.identifier or documentNode properties.

In Wegmeister.DatabaseStorage, we use some logic to resolve the actual nodes created with a Node-based form (Neos.Form.Builder). We use it to extract the speaking labels of the fields. See the code here.