You are here

public function GetServices::simpleNodeImporterGetPreSelectedValues in Simple Node Importer 8

File

src/Services/GetServices.php, line 211

Class

GetServices

Namespace

Drupal\simple_node_importer\Services

Code

public function simpleNodeImporterGetPreSelectedValues($form, $headers) {
  foreach ($form['mapping_form'] as $field => $attributes) {
    if (is_array($attributes)) {
      foreach ($attributes['#options'] as $key => $value) {
        if (array_key_exists($key, $headers) && $headers[$key] == $attributes['#title']) {
          $form['mapping_form'][$field]['#default_value'] = $key;
        }
      }
    }
  }
  return $form;
}