Commit db2927c7 authored by brockfanning's avatar brockfanning Committed by joseph.olstad

Issue #2833135 by brockfanning: Allow multi-value fields to be overridden in WYSIWYG

parent aeb8d82e
......@@ -92,8 +92,12 @@ function media_wysiwyg_format_form($form, &$form_state, $file) {
$instance = field_info_instances('file', $file->type);
foreach ($instance as $field_name => $field_value) {
$info = field_info_field($field_name);
// Only single valued fields can be overridden.
$allow = $info['cardinality'] == 1 && !empty($instance[$field_name]['settings']['wysiwyg_override']);
$allow = !empty($instance[$field_name]['settings']['wysiwyg_override']);
// Only single valued fields can be overridden normally, unless Media is
// configured otherwise with "media_wysiwyg_wysiwyg_override_multivalue".
if ($allow && $info['cardinality'] != 1) {
$allow = variable_get('media_wysiwyg_wysiwyg_override_multivalue', FALSE);
}
$form['options']['fields'][$field_name]['#access'] = $allow;
}
......
......@@ -63,7 +63,7 @@ Drupal.media.formatForm.getOptions = function () {
$.each($('#media-wysiwyg-format-form .fieldset-wrapper *').serializeArray(), function (i, field) {
// Support multi-value select lists, which show up here with [] at the end.
// Support multi-value fields, which show up here with [] at the end.
if ('[]' == field.name.slice(-2)) {
if (typeof fieldDelta[field.name] === 'undefined') {
fieldDelta[field.name] = 0;
......
......@@ -268,7 +268,14 @@ function media_wysiwyg_form_media_admin_config_browser_alter(&$form, &$form_stat
'#title' => t('Override field types in WYSIWYG'),
'#options' => $options,
'#default_value' => variable_get('media_wysiwyg_wysiwyg_override_field_types', array('text', 'text_long')),
'#description' => t('If checked, then the field type may be overridden in the WYSIWYG editor. Not all field types (e.g. Term reference) currently support being overridden so the desired result might not be achieved.')
'#description' => t('If checked, then the field type may be overridden in the WYSIWYG editor. Not all field types/widgets (e.g. Term reference autocomplete) currently support being overridden so the desired result might not be achieved.')
);
$form['wysiwyg']['media_wysiwyg_wysiwyg_override_multivalue'] = array(
'#type' => 'checkbox',
'#title' => t('Override multi-value fields in WYSIWYG'),
'#description' => t('If checked, then multi-value fields may be overridden in the WYSIWYG editor. Not all field types/widgets (e.g. Term reference autocomplete) currently support being overridden so the desired result might not be achieved.'),
'#default_value' => variable_get('media_wysiwyg_wysiwyg_override_multivalue', FALSE),
);
$form['wysiwyg']['media_wysiwyg_use_link_text_for_filename'] = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment