0

In a Joomla 3.x plugin I need to populate some plugin parameters with array data based on dropdown field choice value.

$presets = array( 
    "preset_A" => array
        (
        "parameter_A" => "value_a",     
        "parameter_B" => "value_b",     
        "parameter_C" => "value_c"      
        ),
    "preset_B" => array
        (
        "parameter_A" => "value_a",
        "parameter_B" => "value_b",
        "parameter_C" => "value_c"
        ),
    "preset_C" => array
        (
        "parameter_A" => "value_a",
        "parameter_B" => "value_b",
        "parameter_C" => "value_c"
        )
     );

For instance if the chosen value in dropdown is 'preset_B' it should populate parameter_A ... parameter_C with values of preset_B from the array.

1

If you want to create multiple default values depending on one dropdown field you will need to create a custom list field that will populate data in other fields depending on selected preset option. There is no way (using build in functionality) to make it like this without custom field and javascript.

| improve this answer | |
0

The provided sample data have the same values for preset_A[a-c] all the way to preset_C[a-c]. I'm not sure I understand what you are try'n to do here. Have you tried using the 'showon" attribute, it works in parameter forms as well. showon

Regards

<fieldset name="params">  
    <field name="masterOption" type="list"  >
        <option value="a">A</option>
        <option value="b">B</option>
        <option value="c">C</option>
    </field>

    <field name="subOptionA" type="list" showon="masterOption:a"  >
        <option value="a_a">A</option>
        <option value="a_b">B</option>
        <option value="a_c">C</option>
    </field>

    ...

    <field name="subOptionC" type="list" showon="masterOption:c"  >
        <option value="c_a">A</option>
        <option value="c_b">B</option>
        <option value="c_c">C</option>
    </field>
</fieldset>  

*untested pseudo code, just to give an idea

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.