Add parent option name in child option callback as reference

This commit is contained in:
Champ Camba
2017-11-04 16:36:15 +08:00
parent fbfbf58ad2
commit 2d00af2d85
4 changed files with 12 additions and 14 deletions
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -325,6 +325,7 @@ jQuery(document).ready(function() {
url: um_scripts.ajax_select_options,
type: 'post',
data: {
parent_option_name: parent_option,
parent_option: parent.val(),
child_callback: um_ajax_source,
child_name: me.attr('name'),
+9 -13
View File
@@ -675,10 +675,11 @@
if (in_array( $type, array( 'select', 'multiselect' ) ) && isset( $data['custom_dropdown_options_source'] ) && !empty( $data['custom_dropdown_options_source'] )) {
if (function_exists( $data['custom_dropdown_options_source'] )) {
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
if ( function_exists( $data['custom_dropdown_options_source'] ) ) {
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
if ($type == 'select') {
if (isset( $arr_options[$value] ) && !empty( $arr_options[$value] )) {
return $arr_options[$value];
@@ -726,15 +727,10 @@
*/
function get_options_from_callback( $data, $type ) {
if ( in_array( $type, array( 'select', 'multiselect' ) ) && isset( $data['custom_dropdown_options_source'] ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
if (in_array( $type, array( 'select', 'multiselect' ) ) && isset( $data['custom_dropdown_options_source'] ) && !empty( $data['custom_dropdown_options_source'] )) {
if (function_exists( $data['custom_dropdown_options_source'] )) {
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
}
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
}
@@ -1869,7 +1865,7 @@
$has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) &&
um_user( $data['parent_dropdown_relationship'] )
) {
$options = call_user_func( $data['custom_dropdown_options_source'] );
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
$disabled_by_parent_option = '';
if (um_user( $form_key )) {
$select_original_option_value = " data-um-original-value='" . um_user( $form_key ) . "' ";
+1 -1
View File
@@ -71,7 +71,7 @@ if ( ! class_exists( 'Form' ) ) {
$arr_options['field'] = $form_fields[ $_POST['child_name'] ];
if( function_exists( $ajax_source_func ) ){
$arr_options['items'] = call_user_func( $ajax_source_func );
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
}
}else{