Set HubDB Table value in a HubDB Row field

Hi All,

In a custom module, I have a HubDB Table field and a HubDB Row field and I want to change the HubDB Row table value with the value selected in the HubDB Table field.

I’m trying something like:

{% set module.myhubdb_row_field.table_id = module.myhubdb_table_field %}

But it doesn’t work.

I need this field in the module, so I can select some rows when setting up the module on any page. But the table of this row field must be different on some pages. I don’t want to create different modules for this because it would be repetitive and bad practice.

Any ideas?

Hi @DaniSanchez,

you shouldn’t write

{% set module.NAME = module.NAME2 %}

since this will create an infinite loop of something and you really don’t want that :grinning_face:

A better naming convention is

{% set resources = hubdb_table_row(module.resources_table, module.resources_name_row) %}

you can find more about the hubdb_table_row function here

Also you can always pprint the value of “resources”(or any other function included in the module) by putting

{{ resources|pprint }}

anywhere in the code to debug

best,

Anton

Hi Anton, thanks for your help. Unfortunately, it doesn’t work.
I don’t want to retrieve the rows from a table, but to change the HubDB table dynamically of a HubDB Row field.
For more context, I have this field:

This field has the table “U4_ResourceLibrary_EN”. So in the editor mode, we can select all the rows coming from that table:

Now, I have this table field:

If in the editor mode, I change the table field by selecting a different table, for instance “U4_ResourceLibrary_ES”:

I want that the row field (“Resource Name” field in the screenshot above) extracts data from that table too. But as you can see in the first screenshot, when you create a row field, you need to select a table, I just want to be able to change the source table dynamically.

Hope someone can help! Thanks in advance!

Now, I want to change that table dynamically