Loading Specific Relation Record?

mboegem:
Hi John,

If I understand correctly, you are loading a specific table 2 record and then expect the relation to load the related table 1 record.
This could work when the form was based on table 2, and the relation is table2_to_table1.
Basically everything works from left to right, not the opposite way.

It’s still unclear how you display table 2 records, is that on a tabpanel, or through fields that show the table2 dataprovider over table1_to_table?
When it’s the latter, then what you are trying to do is impossible.
The only thing to resolve this is to do the opposite as explained above, but then you can’t load a table1 record and see the related table2 record (if that’s also needed)

If you really need both in the existing situation, I guess this should work.

  1. load record of table 1 > it will automatically show values of the first record (based on sort order) of table 2
  2. now call table1_to_table2.selectRecord(table2_pk)

Personally I would build the form differently:

  1. form A with table 1 datasource and fields displaying table 1 values
  2. form B with table 2 datasource and fields displaying table 2 values
  3. add form B to form A using a tabpanel (no relation)
  4. when loading records, load correct record on form B, work out related record of table 1 and load correct record on form A

It’s difficult to do all the thinking if we can’t see what your form looks like. A picture tells more than a thousand words.
Although your explanation does contain some rough information, the correct answer can only be given when knowing details and probably also the use case and reasons why you build the current form as it is.

Nevertheless, I hope the above makes sense.

Aha, I didn’t realize you could select the related record through the relation. That might fix it!

My current setup is that the Form has Form Elements like textfields for Table 1 dataproviders, since that’s the DataSource. But then I have a singular HTML Area that has a Table2 dataprovider.

Since it’s only one Form Element I thought I would just use the relation I created and then just manually load the appropriate Table2 record… but I wasn’t sure how to do that till now.

Typically I have been making Forms for each table, and then I use a Form Container to embed and manually load as you mentioned. But I thought it was overkill just to get one form element working.

But if the relation record selection doesn’t work, I suppose I might have to do the 2 Form setup with the Form Container instead.

Thank you for clearing it up!