After uploading a file on a node form values earlier set using a form_alter are lost.
It doesn't seem to matter whether I use #value or #default_value.
Using a hack like altering the $form_state['complete_form'] in a validate doesn't solve the problem because one of the fields is a required field so an error is already set preventing the form from being submitted. (even though the value is set, clicking submit a second time submit's the form)
The fields that are causing the problem are select fields. (one entity reference select list, and a select list (text).
I can't be certain this problem is limited to Drupal 8 Alpha 12 only. (I remember having a similar problem on Drupal 7)
/**
* Implements hook_form_alter()
*/
function test_form_alter(&$form, &$form_state, $form_id) {
// check if field available
if (!empty($form['field_test_field'])) {
$form['field_test_field']['widget']['#value'] = 1;
}
}
Closed: outdated
8.0 β°οΈ
Last updated
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.