I try to set a default text format to a field (Long text) but it's not saved if i don't set a default value for the field.

1. I edit the field
2. I set the Text processing to "Filtered text (user selects text format)"
3. I set "Text format" to a another text format
4. Then i save

If i also set a default value for my field, my text format is set as default
But if i leave the default value of my field, it's not saved.

The function "text_field_is_empty (field/modules/text/text.module - line 51-)" is called. This function check only the value for the field, not the format. It return true and the function "_field_filter_items (field/field.module - line 51-)" unset this item including my text format.

If i change the function function text_field_is_empty

function text_field_is_empty($item, $field) {
  if ((!isset($item['value']) || $item['value'] === '') && (!isset($item['format']) || $item['format'] === '')) {
    return !isset($item['summary']) || $item['summary'] === '';
  }
  return FALSE;
}

to

function text_field_is_empty($item, $field) {
  if (!isset($item['value']) || $item['value'] === '')) {
    return !isset($item['summary']) || $item['summary'] === '';
  }
  return FALSE;
}

my text format is set as default event i don't enter a default value for my field.

But i'm not sure it's the good way to fix this issue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rahul1705 created an issue. See original summary.

joseph.olstad’s picture

Title: Default text formats are not saved properly without accompanying values » D7 Default text formats are not saved properly without accompanying values
Version: 7.44 » 7.x-dev
Component: text.module » field system
Issue summary: View changes
Status: Active » Postponed
FileSize
1.66 KB

See updated re-rolled D7 patch.

Otherwise, postponed on #1278886: Default text formats are not saved properly without accompanying values

joseph.olstad’s picture

Assigned: rahul1705 » Unassigned
joseph.olstad’s picture

klonos’s picture

Issue summary: View changes

I have updated the issue summary because the previous one was D8-specific. The updated one is a copy-paste of the original report from #1278886: Default text formats are not saved properly without accompanying values

torotil’s picture

apaderno’s picture

Issue tags: -Filtered HTML save issue without default text