-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello, I hope this guide helps you set up the two-level subform structure like in the Demo 5 component (Countries → States → Cities). Below is a simplified breakdown of how to structure both ✅ Step 1: Define the
|
Level | Table | Links To | linkKey | linkValue |
---|---|---|---|---|
Country | ||||
↳ State | state | country GUID | country | $data['guid'] or $item->guid |
↳↳ City | city | state GUID | state | 'state:guid' |
Once your linking fields and table references are correct, this structure will handle complex multi-table inputs smoothly!
Beta Was this translation helpful? Give feedback.
-
Hallo Lemuel
Thank you very much for your detail explanations. Unfortunately I can not do it yet. Maybe it’s because of the field state (marked yellow below).
What do you mean with ‘Identifier used in code to access the data (state)’? Witch object is mentioned here? May I ask you to explain it?
Thank you and greetings
Rachel
Von: Lemuel ***@***.***>
Gesendet: Montag, 9. Juni 2025 18:11
An: vdm-io/Joomla-Component-Builder ***@***.***>
Cc: STAR ***@***.***>; Author ***@***.***>
Betreff: Re: [vdm-io/Joomla-Component-Builder] Two-step Subform (Discussion #989)
Hello, I hope this guide helps you set up the two-level subform structure like in the Demo 5 component (Countries → States → Cities). Below is a simplified breakdown of how to structure both set and get operations to make everything work seamlessly.
…_____
✅ Step 1: Define the SET Map
The setMap tells the system how to link and save data from the subforms.
$setMap = [
'_core' => [ // Parent subform: States
'table' => 'state', // Table storing parent subform data
'indexKey' => 'guid', // Unique ID field for states
'linkKey' => 'country', // Field linking state to country
'linkValue' => $data['guid'] ?? '' // Current country GUID
],
'cities' => [ // Child subform: Cities
'table' => 'city', // Table storing child subform data
'indexKey' => 'guid', // Unique ID field for cities
'linkKey' => 'state', // Field linking city to state
'linkValue' => 'state:guid' // Reference to parent's GUID
]
];
Super___9d76b8dc_3883_4755_b11c_131d19ca8a53___Power::_('Data.MultiSubform')->set([[[field]]] ?? [], $setMap);
_____
✅ Step 2: Define the GET Map
The getMap is for retrieving the existing data for editing/viewing.
$getMap = [
'_core' => [ // Parent subform: States
'table' => 'state',
'linkValue' => $item->guid ?? '', // Current country GUID
'linkKey' => 'country',
'field' => 'state', // Name used for storing states
'get' => ['guid','name','type','latitude','longitude','iso2','fips_code','wikidataid']
],
'cities' => [ // Child subform: Cities
'table' => 'city',
'linkValue' => 'state:guid', // Pull cities by their linked state
'linkKey' => 'state',
'get' => ['guid','name','latitude','longitude','wikidataid']
]
];
[[[field]]] = Super___9d76b8dc_3883_4755_b11c_131d19ca8a53___Power::_('Data.MultiSubform')->get($getMap);
_____
📘 Concept Breakdown
🔷 1. SET Parent Subform (States)
* table: Where data is saved (state)
* indexKey: Unique ID used (guid)
* linkKey: Foreign key in state table that links to the parent table (country)
* linkValue: The GUID of the current country (usually $data['guid'] ?? '')
🔷 2. SET Child Subform (Cities)
* table: Table to store cities (city)
* indexKey: Unique ID (guid)
* linkKey: Foreign key in the city table that links to state
* linkValue: 'state:guid' means “use the guid field from the parent subform (state)”
🔷 3. GET Parent Subform
* table: Where data is retrieved from (state)
* linkValue: Current country GUID ($item->guid ?? '')
* linkKey: Field in state that links it to country
* field: Identifier used in code to access the data (state)
* get: List of fields to retrieve from the state table
🔷 4. GET Child Subform
* table: Data comes from city
* linkValue: 'state:guid' – links to the current state's GUID
* linkKey: The field in city that connects it to state
* get: Fields to retrieve from the city table
_____
_____
🧠 Summary
Level
Table
Links To
linkKey
linkValue
Country
↳ State
state
country GUID
country
$data['guid'] or $item->guid
↳↳ City
city
state GUID
state
'state:guid'
Once your linking fields and table references are correct, this structure will handle complex multi-table inputs smoothly!
—
Reply to this email directly, view it on GitHub <https://github.com/vdm-io/Joomla-Component-Builder/discussions/989#discussioncomment-13411757> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AXXRM6LNM3A7B4B53HF76XL3CWWXVAVCNFSM6AAAAAB65EPEASVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGNBRGE3TKNY> .
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Hello, I hope this guide helps you set up the two-level subform structure like in the Demo 5 component (Countries → States → Cities). Below is a simplified breakdown of how to structure both
set
andget
operations to make everything work seamlessly.✅ Step 1: Define the
SET
MapThe
setMap
tells the system how to link and save data from the subforms.