Created
August 5, 2020 11:02
-
-
Save reachkamrul/996211d7a9c8beb024accbddd8e8aa93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Dynamic item in fluent form dropdown. | |
*/ | |
add_filter('fluenform_rendering_field_data_select', function ($data, $form) { | |
if ($form->id != 91) { | |
return $data; | |
} | |
// do the dynamic part if and only the name attriibute is 'dynamic_dropdown' | |
// Please use the corresponding field name for your case. | |
// For checkbox: fluenform_rendering_field_data_input_checkbox | |
// For Radio: fluenform_rendering_field_data_input_radio | |
// For Select: fluenform_rendering_field_data_select | |
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'dynamic_dropdown') { | |
return $data; | |
} | |
// We are merging with existing options here | |
$data['settings']['advanced_options'] = array_merge($data['settings']['advanced_options'], [ | |
[ | |
"label" => "Dynamic Option 1", | |
"value" => "Dynamic Option 1", | |
"calc_value" => "" | |
], | |
[ | |
"label" => "Dynamic Option 2", | |
"value" => "Dynamic Option 2", | |
"calc_value" => "" | |
] | |
]); | |
return $data; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment