Send variable from Module to Submodules?

Hello,
I have created a select module where the optionelements are submodules.
But now i have the problem to get the selectfield name inside the options to give them a selected attribute on a pagereload. Is there a possibility to send a variable from a module to a submodule like in the snippets?

Or is it really necessary to rebuild my selectforms?

Best

Are we talking about the modules plugin here?

Yes indeed. Sorry that I don’t clearify that in my post.

I have reread your post multiple times but I still don’t understand what you are trying to achieve, I’m afraid.

So you have a module with a select field and you have the children of this module as options like this?

# module bleuprint
fields:
  myselectfield:
    label: Select a submodule
    type: select
    options: children

Is that correct? So the user selects a child. But then what? And where, in a template I suppose? Maybe post the code to make it easier to understand.

Modules are not supposed to have children, btw.

Hello Sonja,
also, I have one module for the select-element and one for the option elements.
In the default.yml Blueprint I call the modules field

  modules:
    label: Inhaltselemente
    type: modules
    options:
      preview: true

and than I have a blueprint modules.yml where I select all moduletemplates

title: Module
pages:
  template:
    - module.select
    …
    
hide: true

fields:
  title:
    label: Title
    type: text

and than also the submodule blueprint modules-select.yml

title: Module
hide: true
pages:
  template:
    - module.option

fields:
  title:
    label: Title
    type: text
    
  modules:
    label: Inhaltselemente
    type: modules
    options:
      preview: true

where I call the option-elements. Also I have the modules cascaded like pages.
And I need a variable from site/modules/select/select.html.php in site/modules/option/option.html.php

Best, Jan

The modules function and method behave like the snippet() function. $data can be used to provide additional data to all modules and $return can be set to true to return the HTML code instead of printing it.

1 Like

Thank you very much Sonja.
I have tried this before but it havn’t work. Because I had a lot of syntax mistakes in it.
And I was not feel certain that it is the same function like in the snippets.

Best