[SOLVED] Form Finisher: Get Form as NodeType


(Burak Kavak) #1

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?


(Sebastian Helzle) #2

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);

(Burak Kavak) #3

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: