Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Drupal 8 custom form image field

//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 by drupal.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #Drupal #custom #form #image #field
ADD COMMENT
Topic
Name
8+9 =