Drupal 8 Custom Form Image Field

[Solved] Drupal 8 Custom Form Image Field | Php Frameworks Drupal - Code Explorer | yomemimo.com
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

Answers related to Drupal 8 custom form image field

Code Explorer Popular Question For Php Frameworks Drupal