Popup Inside Multi Not Returning Array
I have the following option. [multi][popup]. When I pace the option in pagebuilder I get an empty string for the value of the popup. See Example 1. The array values don't get added until I hit save in the popup even though defaults are set. So, $foo = [ foo][option-1][bar] will cause an illegal string offset unless I save the popup.
Example 1)
[foo]
(
[option-1] => 'value 1'
[option-2] => ''
)
Example2)
[foo]
(
[option_1] => ''
[option_2] => array
(
[bar] => '0'
)
)
Looks like the documentation is wrong on multi because if you set value array:
array(
'type' => 'multi',
'value' => array(
'option-1' => 'value 1',
'option-2' => 'value 2',
),
then the if:
if (
is_array($input_value) ||
empty($option['value'])
)
doesn't fire the foreach to get values for any sub options. Instead it just returns $value = $option['value']. If option-2 is a popup which an empty string value this flags an exception.
Is the $input_value arg from the html input of the option?
I'm going to close this issue and just note that the documentation is incomplete.
Basically if you are nesting and multi or popup inside another multi or popup do NOT set 'value' for the multi or popup. That way the class will generate default values with empty array and the if will fire the foreach and call the render for any nested options.
Thank you.
You can improve any time you want the documentation by submitting pull requests https://github.com/ThemeFuse/Unyson-Documentation It is not hard, you can do all the work directly on site (fork, edit, pull request) without working with git commands on your pc