I am trying to update a DateTime field in an altered form submit. Something like:
php function my_module_form_submit($form, FormStateInterface $form_state) { if (!$profile->field_someother_field->isEmpty()) { $date = new DrupalDateTime(); $date->setTimezone(new DateTimezone(DATETIME_STORAGE_TIMEZONE)); $string = $date->format(DATETIME_DATETIME_STORAGE_FORMAT); $form_state->setValue('field_date_updated_details', [$string]); } }
But this fails with various messages (depending on whether I set the value as an array or directly as string).
Any advice?