How to render custom data from repository in a Fusion RuntimeForm?

Hi, I’m using the Neos.Fusion.Form:Runtime.RuntimeForm and would like to render some data from the repository by getting the data with ${q(node).property('myLegendTitle')} and use it in the AFX code in “content” property for the form body. But somehow it does not work. What I’m doing wrong?

Or is it also possible to use Translation texts? I have seen this https://github.com/neos/fusion-form/blob/master/Documentation/FusionReference.rst#neosfusionformfieldcontainer and according to the docs the label is translated with “translations.label.package” but I don’t understand yet how this can be used finally.

Thx for help!

Here the snippet:

  renderer = Neos.Fusion.Form:Runtime.RuntimeForm {
    namespace = 'contact'

    process {
      formLegendTitle = ${q(node).property('formLegendTitle')}
      content = afx`
        <fieldset>
          <legend>{props.formLegendTitle}</legend>
          ...
       </fieldset>
       ...

Why not …

Runtime Form is not a Fusion:Component if you need props you can wrap it into one

 prototype(Vendor.Site:ExampleForm) < prototype(Neos.Fusion:Component) {    
   formLegendTitle = ${q(node).property('formLegendTitle')}

   renderer = Neos.Fusion.Form:Runtime.RuntimeForm {
     namespace = 'contact'
     process {
      content = afx`
          <fieldset>
          <legend>{props.formLegendTitle}</legend>
      ...
   </fieldset>
1 Like

Thanks @martoro !

This was simple :slight_smile:

The direct usage of q(node).property('formLegendTitle') has worked.

But wrapping the form in a Fusion:Component did not work for me. Somehow the props seems to be empty.

That is right and an unexpected side effect of the form beeing uncached by default.

Reason is that the cache annotation in https://github.com/neos/fusion-form/blob/master/Resources/Private/Fusion/Prototypes/Runtime/RuntimeForm.fusion ensures that only site, node and documentNode are persisted.

You could do this:

prototype(Vendor.Site:ExampleForm) < prototype(Neos.Fusion:Component) {

  // then whole form component is made uncached 
  @cache {
    mode = 'uncached'
    context {
        1 = 'node'
        2 = 'documentNode'
        3 = 'site'
    }
  }    
  formLegendTitle = ${q(node).property('formLegendTitle')}
  renderer = Neos.Fusion.Form:Runtime.RuntimeForm {

    // so the inner form can be embedded and share the props
    @cache.mode = "embed"

    namespace = 'contact'
    process {
      content = afx`
          <fieldset>
          <legend>{props.formLegendTitle}</legend>
2 Likes

Thanks for the explanation. With this using “props” worked also.