function _select2_set_element_settings in Select 2 7
Element settings.
Parameters
string $element_id: Element id
array $settings: Settings
3 calls to _select2_set_element_settings()
- select2_process_textfield in ./
select2.module - Process textfield.
- select2_select_element_process in ./
select2.module - Select element process.
- select2_taxonomy_term_reference_validate in ./
select2.module - Validate term references.
File
- ./
select2.module, line 1228 - Main file for Select2 module.
Code
function _select2_set_element_settings($element_id, $settings) {
$js =& drupal_static('drupal_add_js', array());
if (!isset($js['settings']) || !isset($js['settings']['data'])) {
drupal_add_js(array(
'select_2' => array(
'elements' => array(
$element_id => $settings,
),
),
), 'setting');
return;
}
$js_setting_key =& drupal_static('select2_js_setting_key', -1);
if ($js_setting_key == -1) {
foreach ($js['settings']['data'] as $key => $data) {
foreach ($data as $scope_name => $scope_data) {
if ($scope_name == 'select_2') {
$js_setting_key = $key;
}
}
}
}
if ($js_setting_key == -1) {
drupal_add_js(array(
'select_2' => array(
'elements' => array(
$element_id => $settings,
),
),
), 'setting');
return;
}
if (!isset($js['settings']['data'][$js_setting_key]['select_2']['elements'][$element_id])) {
$js['settings']['data'][$js_setting_key]['select_2']['elements'][$element_id] = $settings;
}
else {
$js['settings']['data'][$js_setting_key]['select_2']['elements'][$element_id] = array_replace_recursive($js['settings']['data'][$js_setting_key]['select_2']['elements'][$element_id], $settings);
}
}