Commit ce1cc587 authored by webchick's avatar webchick
Browse files

#553292 by yched: Fixed bug with formatter settings getting lost when saving a field.

parent 770e0d54
...@@ -654,7 +654,6 @@ function template_preprocess_field_ui_display_overview_form(&$vars) { ...@@ -654,7 +654,6 @@ function template_preprocess_field_ui_display_overview_form(&$vars) {
* Submit handler for the display overview form. * Submit handler for the display overview form.
*/ */
function field_ui_display_overview_form_submit($form, &$form_state) { function field_ui_display_overview_form_submit($form, &$form_state) {
module_load_include('inc', 'field', 'includes/field.crud');
$form_values = $form_state['values']; $form_values = $form_state['values'];
foreach ($form_values as $key => $values) { foreach ($form_values as $key => $values) {
if (in_array($key, $form['#fields'])) { if (in_array($key, $form['#fields'])) {
...@@ -873,9 +872,6 @@ function field_ui_field_settings_form_submit($form, &$form_state) { ...@@ -873,9 +872,6 @@ function field_ui_field_settings_form_submit($form, &$form_state) {
return; return;
} }
// Remove the 'bundles' element added by field_info_field.
// @todo This is ugly, there must be a better way.
unset($field['bundles']);
$bundle = $form['#bundle']; $bundle = $form['#bundle'];
$instance = field_info_instance($field['field_name'], $bundle); $instance = field_info_instance($field['field_name'], $bundle);
...@@ -1275,26 +1271,25 @@ function field_ui_field_edit_form_validate($form, &$form_state) { ...@@ -1275,26 +1271,25 @@ function field_ui_field_edit_form_validate($form, &$form_state) {
*/ */
function field_ui_field_edit_form_submit($form, &$form_state) { function field_ui_field_edit_form_submit($form, &$form_state) {
$form_values = $form_state['values']; $form_values = $form_state['values'];
$instance = $form_values['instance']; $field_values = $form_values['field'];
$field_name = $instance['field_name']; $instance_values = $form_values['instance'];
$field_name = $instance_values['field_name'];
// Update any field settings that have changed. // Update any field settings that have changed.
$field = field_info_field($field_name); $field = field_info_field($instance_values['field_name']);
// Remove the 'bundles' element added by field_info_field. $field = array_merge($field, $field_values);
// @todo This is ugly, there must be a better way.
unset($field['bundles']);
$field = array_merge($field, $form_state['values']['field']);
field_ui_update_field($field); field_ui_update_field($field);
// Move the default value from the sample widget to the default value field. // Move the default value from the sample widget to the default value field.
if (isset($instance['default_value_widget'])) { if (isset($instance_values['default_value_widget'])) {
$langcode = $form['instance']['default_value_widget'][$field_name]['#language']; $langcode = $instance_values['default_value_widget'][$field_name]['#language'];
$instance['default_value'] = $instance['default_value_widget'][$field_name][$langcode]; $instance_values['default_value'] = $instance_values['default_value_widget'][$field_name][$langcode];
unset($instance['default_value_widget']); unset($instance_values['default_value_widget']);
} }
// Update the instance settings. // Update the instance settings.
module_load_include('inc', 'field', 'includes/field.crud'); $instance = field_info_instance($instance_values['field_name'], $instance_values['bundle']);
$instance = array_merge($instance, $instance_values);
field_update_instance($instance); field_update_instance($instance);
drupal_set_message(t('Saved %label configuration.', array('%label' => $instance['label']))); drupal_set_message(t('Saved %label configuration.', array('%label' => $instance['label'])));
......
...@@ -253,6 +253,9 @@ function field_ui_update_field($field) { ...@@ -253,6 +253,9 @@ function field_ui_update_field($field) {
$field_types = field_info_field_types(); $field_types = field_info_field_types();
$module = $field_types[$field['type']]['module']; $module = $field_types[$field['type']]['module'];
// If needed, remove the 'bundles' element added by field_info_field.
unset($field['bundles']);
$defaults = field_info_field_settings($field['type']); $defaults = field_info_field_settings($field['type']);
$field['settings'] = array_merge($defaults, (array) $field['settings']); $field['settings'] = array_merge($defaults, (array) $field['settings']);
$data = $field; $data = $field;
......
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