Question : Drupal 8 custom form image field
Answered by : graceful-gecko-92l82avnw1mi
//form build
$form['my_file'] = [ '#type' => 'managed_file', '#title' => 'my file', '#name' => 'my_custom_file', '#description' => $this->t('my file description'), '#default_value' => [$config->get('my_file')], '#upload_location' => 'public://' ];
//form submit
$form_state->getValue('my_file')[0];
Source : https://drupal.stackexchange.com/questions/272796/how-to-add-image-field-in-a-custom-module-form | Last Update : Tue, 19 Oct 21