Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
1. Create a content type
2. Add a Long text field with a Text area/Multiple rows widget
3. Use a WYSIWYG format
4. Add default data
5. Create a new node with CT
6. Delete default content
7. Save node
8. Deleted content is still there.
At this point, if one edits the node and then deletes the default content and saves, it is deleted.
Another note, if instead of deletion, one edits the default text, it is saved properly the first time (i.e. the original default text isn't reinserted).
This behavior may exist for other field types, just noticed it on the text field type at this time.
Comments
Comment #1
jastraat CreditAttribution: jastraat commentedStill an issue
I believe this is because _field_invoke_default() assumes that if a field is empty, the default needs to be added. This is great in the case of a pro-grammatically created node. However, if someone is adding a new node through the user interface, they will not be allowed to clear the default value for any field - even if it is not required.
Comment #2
fawzi CreditAttribution: fawzi commentedhello ,
i have a form with 2 textfields within a fieldset. Both have some assigned #default_value. when i test the form, the first textfield would print out the content entered in that textfield correctly. However the second textfield would always print out the #default_value. No matter what i type in the form the valus is always the #default_value. I have no idea what is causing this. The two textfields are pretty much identical in all their attributes and location in the form.
any ideas would be great.. i wasted many hours on this issue...
thanks,
here is the code:
// Form Fieldset
$form['myFieldset'] = array(
'#title' => t('Pricelists Config Options'),
'#type' => 'fieldset',
'#prefix' => '
'#suffix' => '
',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
//TextField 1
$form['myFieldset']['TextField_1'] = array(
'#title' => t('TextField 1),
'#type' => 'textfield',
'#required' => FALSE,
'#size' => 5,
'#maxlength' => 256,
'#weight' => $weight++,
'#default_value' => t('1.00'),
);
//TextField 2
$form['myFieldset']['TextField 2'] = array(
'#title' => t('TextField 2'),
'#type' => 'textfield',
'#required' => FALSE,
'#size' => 5,
'#maxlength' => 256,
'#weight' => $weight++,
'#default_value' => t('TextField 2'),
);
Comment #3
jastraat CreditAttribution: jastraat commentedWhile you may have a support question, please don't override a core field issue.
Comment #4
fawzi CreditAttribution: fawzi commentedAfter many attempts i figured out what was causing the problem.
if you look at my naming, i had an underscore in the 1st, and a space in the 2nd.
Changing:
$form['myFieldset']['TextField 2'] to $form['myFieldset']['TextField_2']
Moreover, i found out that periods in a name do not work either so ['U.S. drupal'] and ['U.S._drupal'] would fail while ['US_drupal'] would not.
i am not sure what you want to do with this or where the fix should be, but it seems that it is an error for me that needs fixing...
thanks,
Fawzi
Comment #5
tim.plunkettUnfortunately, there is no way to know if that field was supposed to retain its value, or if it was truly representing the default. If the behavior were to change, it would be confusing and data-destructive.
Comment #6
Jon Betts CreditAttribution: Jon Betts commentedHmmm...I would think that by deleting the data, I'm letting it know that the data shouldn't be there.
Comment #7
yched CreditAttribution: yched commentedThis is an actual bug, dupe of #1253820: It's impossible to submit no value for a field that has a default value. That other thread is newer, but gathered more insight.