当前位置: 首页>>代码示例>>PHP>>正文


PHP ExtraField::extra_field_double_select_convert_array_to_ordered_array方法代码示例

本文整理汇总了PHP中ExtraField::extra_field_double_select_convert_array_to_ordered_array方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtraField::extra_field_double_select_convert_array_to_ordered_array方法的具体用法?PHP ExtraField::extra_field_double_select_convert_array_to_ordered_array怎么用?PHP ExtraField::extra_field_double_select_convert_array_to_ordered_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExtraField的用法示例。


在下文中一共展示了ExtraField::extra_field_double_select_convert_array_to_ordered_array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_extra_fields_in_form


//.........这里部分代码省略.........
                        $form->applyFilter('theme', 'trim');
                        break;
                    case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
                        $first_select_id = 'first_extra_' . $field_details['field_variable'];
                        $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php?1=1';
                        $jquery_ready_content .= '
                        $("#' . $first_select_id . '").on("change", function() {
                            var id = $(this).val();
                            if (id) {
                                $.ajax({
                                    url: "' . $url . '&a=get_second_select_options",
                                    dataType: "json",
                                    data: "type=' . $type . '&field_id=' . $field_details['id'] . '&option_value_id="+id,
                                    success: function(data) {
                                        $("#second_extra_' . $field_details['field_variable'] . '").empty();
                                        $.each(data, function(index, value) {
                                            $("#second_extra_' . $field_details['field_variable'] . '").append($("<option/>", {
                                                value: index,
                                                text: value
                                            }));
                                        });
                                    },
                                });
                            } else {
                                $("#second_extra_' . $field_details['field_variable'] . '").empty();
                            }
                        });';
                        $first_id = null;
                        $second_id = null;
                        if (!empty($extraData)) {
                            $first_id = $extraData['extra_' . $field_details['field_variable']]['extra_' . $field_details['field_variable']];
                            $second_id = $extraData['extra_' . $field_details['field_variable']]['extra_' . $field_details['field_variable'] . '_second'];
                        }
                        $options = ExtraField::extra_field_double_select_convert_array_to_ordered_array($field_details['options']);
                        $values = array('' => get_lang('Select'));
                        $second_values = array();
                        if (!empty($options)) {
                            foreach ($options as $option) {
                                foreach ($option as $sub_option) {
                                    if ($sub_option['option_value'] == '0') {
                                        $values[$sub_option['id']] = $sub_option['option_display_text'];
                                    } else {
                                        if ($first_id === $sub_option['option_value']) {
                                            $second_values[$sub_option['id']] = $sub_option['option_display_text'];
                                        }
                                    }
                                }
                            }
                        }
                        $group = array();
                        $group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'], null, $values, array('id' => $first_select_id));
                        $group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'] . '_second', null, $second_values, array('id' => 'second_extra_' . $field_details['field_variable']));
                        $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], '&nbsp;');
                        if (!$admin_permissions) {
                            if ($field_details['field_visible'] == 0) {
                                $form->freeze('extra_' . $field_details['field_variable']);
                            }
                        }
                        break;
                    case ExtraField::FIELD_TYPE_DIVIDER:
                        $form->addElement('static', $field_details['field_variable'], '<br /><strong>' . $field_details['field_display_text'] . '</strong>');
                        break;
                    case ExtraField::FIELD_TYPE_TAG:
                        $field_variable = $field_details['field_variable'];
                        $field_id = $field_details['id'];
                        if ($this->type == 'user') {
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:67,代码来源:extra_field.lib.php

示例2: set_extra_fields_in_form


//.........这里部分代码省略.........
                        $form->applyFilter('theme', 'trim');
                        break;
                    case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
                        $first_select_id = 'first_extra_' . $field_details['variable'];
                        $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php?1=1';
                        $jquery_ready_content .= '
                        $("#' . $first_select_id . '").on("change", function() {
                            var id = $(this).val();
                            if (id) {
                                $.ajax({
                                    url: "' . $url . '&a=get_second_select_options",
                                    dataType: "json",
                                    data: "type=' . $type . '&field_id=' . $field_details['id'] . '&option_value_id="+id,
                                    success: function(data) {
                                        $("#second_extra_' . $field_details['variable'] . '").empty();
                                        $.each(data, function(index, value) {
                                            $("#second_extra_' . $field_details['variable'] . '").append($("<option/>", {
                                                value: index,
                                                text: value
                                            }));
                                        });
                                    },
                                });
                            } else {
                                $("#second_extra_' . $field_details['variable'] . '").empty();
                            }
                        });';
                        $first_id = null;
                        $second_id = null;
                        if (!empty($extraData)) {
                            $first_id = $extraData['extra_' . $field_details['variable']]['extra_' . $field_details['variable']];
                            $second_id = $extraData['extra_' . $field_details['variable']]['extra_' . $field_details['variable'] . '_second'];
                        }
                        $options = ExtraField::extra_field_double_select_convert_array_to_ordered_array($field_details['options']);
                        $values = array('' => get_lang('Select'));
                        $second_values = array();
                        if (!empty($options)) {
                            foreach ($options as $option) {
                                foreach ($option as $sub_option) {
                                    if ($sub_option['option_value'] == '0') {
                                        $values[$sub_option['id']] = $sub_option['display_text'];
                                    } else {
                                        if ($first_id === $sub_option['option_value']) {
                                            $second_values[$sub_option['id']] = $sub_option['display_text'];
                                        }
                                    }
                                }
                            }
                        }
                        $group = array();
                        $group[] = $form->createElement('select', 'extra_' . $field_details['variable'], null, $values, array('id' => $first_select_id));
                        $group[] = $form->createElement('select', 'extra_' . $field_details['variable'] . '_second', null, $second_values, array('id' => 'second_extra_' . $field_details['variable']));
                        $form->addGroup($group, 'extra_' . $field_details['variable'], $field_details['display_text'], '&nbsp;');
                        if (!$admin_permissions) {
                            if ($field_details['visible'] == 0) {
                                $form->freeze('extra_' . $field_details['variable']);
                            }
                        }
                        break;
                    case ExtraField::FIELD_TYPE_DIVIDER:
                        $form->addElement('static', $field_details['variable'], '<br /><strong>' . $field_details['display_text'] . '</strong>');
                        break;
                    case ExtraField::FIELD_TYPE_TAG:
                        $variable = $field_details['variable'];
                        $field_id = $field_details['id'];
                        //Added for correctly translate the extra_field
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:67,代码来源:extra_field.lib.php


注:本文中的ExtraField::extra_field_double_select_convert_array_to_ordered_array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。