form-builder icon indicating copy to clipboard operation
form-builder copied to clipboard

Render options correctly

Open Baachi opened this issue 6 months ago • 2 comments

I debugged a little bit, why options are not rendered currently (as mentioned in #150). It seems that the Neos.Form.Builder:SelectOptionCollection/itemRenderer didn't fetched the properties, it just returns null which is stripped out by the implementation.

fixes #150

Baachi avatar Aug 27 '25 19:08 Baachi

@dlubitz You had touched this implementation with #144 – can you judge whether this fix makes sense? To me it seems sensible, but I don't know all the implications

bwaidelich avatar Sep 05 '25 09:09 bwaidelich

Thank you @Baachi for this PR. But this fix might work, but isn't correct at this place. The Neos.Form.Builder:SelectOptionCollection is not aware of the items it get's passed. This needs to be implemented on the using side.

See: https://github.com/neos/form-builder?tab=readme-ov-file#dynamic-options

In this case AFAIS it needs to be implemented here: https://github.com/neos/form-builder/blob/3ec4c7dd427082584a1430b647a8aea9c86becc3/Resources/Private/Fusion/NodeBased/NodeBasedFormElement.fusion#L15-L20

dlubitz avatar Sep 05 '25 10:09 dlubitz

Hey people, can you ellaborate on the fix, please? Since @bwaidelich approach seems not to be correct?

What actually does need to be changed here

[email protected] = Neos.Form.Builder:SelectOptionCollection { 
     items = ${q(elementNode).children('options').children()} 
     valuePropertyPath = 'properties.value' 
     labelPropertyPath = 'properties.label' 
     @if.isSelectFormElement = ${q(elementNode).is('[instanceof Neos.Form.Builder:SelectionMixin]')} 
 }

to render the options again? Maybe I'm just stupid and don't get it right now (probably), but I really need the options to be rendered correctly again.

samsauter avatar Nov 27 '25 13:11 samsauter

Hi @samsauter, have you alreday checked the docs: https://github.com/neos/form-builder?tab=readme-ov-file#dynamic-options

Instead of providing the property paths (valuePropertyPath, labelPropertyPath) you need to provide a itemRenderer. For example something like:

[email protected] = Neos.Form.Builder:SelectOptionCollection { 
     items = ${q(elementNode).children('options').children()} 
     itemRenderer = Neos.Fusion:DataStructure {
        value = ${item.aggregateId}
        label = ${q(item).property('title')}
    }
     @if.isSelectFormElement = ${q(elementNode).is('[instanceof Neos.Form.Builder:SelectionMixin]')} 
 }

(not tested)

dlubitz avatar Nov 27 '25 13:11 dlubitz

Ahh! Well, it's certainly helpful to think for more than two seconds! Thank you!

samsauter avatar Nov 27 '25 13:11 samsauter