Summary
I am trying to find a way to create nested listboxes where the second listbox will display its options based on what is selected on the first lisbox, but I was not able to find any similar use case.
Checked on the file migxformlayouts.config.inc.php
, but didn’t find anything that could be used for this particular situation.
Step to reproduce
Here is the config json with the particular example I am trying to create;
{
"MIGX_id":1,
"caption":"Data",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":1,
"field":"author",
"caption":"Author",
"description":"Select an author",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"listbox",
"validation":"required",
"configs":{
"allowBlank":"false",
"listWidth":"",
"title":"",
"typeAhead":"false",
"typeAheadDelay":"250",
"listEmptyText":"",
"stackItems":"false"
},
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"@SELECT '-' AS `author` UNION ALL (SELECT `name` AS `author`, id FROM `[[+PREFIX]]authors` WHERE `published` = 1)",
"default":"",
"useDefaultIfEmpty":"0",
"pos":1
},
{
"MIGX_id":2,
"field":"book",
"caption":"Choose a book",
"description":"Choose a book from the selected author on the previous box",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"listbox",
"validation":"required",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"@SELECT '' AS `book` UNION ALL (SELECT `[[+PREFIX]]books`.`name` AS `book`, `[[+PREFIX]]books`.`id` FROM `[[+PREFIX]]books` INNER JOIN `[[+PREFIX]]authors` ON `[[+PREFIX]]authors`.`id` = `[[+PREFIX]]books`.`author_id` WHERE `[[+PREFIX]]books`.`published` = '1' AND `[[+PREFIX]]authors`.`published` = '1' AND `[[+PREFIX]]authors`.`id` = '[[+author]]' ORDER BY `[[+PREFIX]]books`.`id` DESC)",
"default":"",
"useDefaultIfEmpty":"0",
"pos":2
}
],
"pos":1
}
The SQL is working. I tested this filling in an ID by hand simulating the author, and worked properly.
Observed behavior
When selecting an option on the first lisbox, the second box is not updated.
Expected behavior
Maybe this already exists, but I was not able to find this information, but maybe there is an option to enable listbox dependencies.
Environment
MODX 2.7.1 with Migx 2.12.0-pl
Thank you in advance for your help.