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.
Comment | File | Size | Author |
---|---|---|---|
#7 | 2852019-field-empty-defaults-7.patch | 2.23 KB | torotil |
Comments
Comment #2
joseph.olstadSee updated re-rolled D7 patch.
Otherwise, postponed on #1278886: Default text formats are not saved properly without accompanying values
Comment #3
joseph.olstadComment #4
joseph.olstadComment #5
klonosI 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
Comment #6
torotil CreditAttribution: torotil at more onion commentedIt seems that the patch needs work as it might lead to issues like #2102613: If node saves without setting value, PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 occurs.
Comment #7
torotil CreditAttribution: torotil at more onion commentedHere is an updated patch that doesn’t trigger #2102613: If node saves without setting value, PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 occurs.
Comment #8
apaderno