Commit 4c6a4d40 authored by Ilias Dimopoulos's avatar Ilias Dimopoulos Committed by Claudiu Cristea
Browse files

Issue #3271100 by idimopoulos: Not all field properties appear in the entity type edit form

parent cbed24cf
Loading
Loading
Loading
Loading
+19 −12
Original line number Diff line number Diff line
@@ -284,35 +284,42 @@ function sparql_entity_storage_form_alter(&$form, FormStateInterface $form_state
    if ($field_name === $id_key) {
      continue;
    }
    $columns = $base_field->getColumns();
    foreach ($columns as $column_name => $column) {
      $title = $base_field->getLabel();
      if (count($columns) > 1) {
        $title .= ' (' . $column_name . ')';
      }

    $title = $base_field->getLabel();
    $form['sparql_entity_storage']['base_fields_mapping'][$field_name] = [
      '#type' => 'details',
      '#title' => $title,
      '#description' => $base_field->getDescription(),
    ];

    $columns = $base_field->getColumns();
    foreach ($columns as $column_name => $column) {
      $column_title = $base_field->getLabel();
      if (count($columns) > 1) {
        $column_title = $title . ' (' . $column_name . ')';
      }

      $has_mapping = $mapping && $mapping->getMapping($field_name, $column_name);
      $form['sparql_entity_storage']['base_fields_mapping'][$field_name][$column_name]['predicate'] = [
        '#type' => 'url',
        '#title' => t('Mapping'),
        '#title' => t(':field_title mapping', [
          ':field_title' => $column_title,
        ]),
        '#description' => t('The RDF predicate.'),
        '#weight' => 150,
        '#default_value' => $mapping ? $mapping->getMapping($field_name, $column_name)['predicate'] : NULL,
        '#default_value' => $has_mapping ? $mapping->getMapping($field_name, $column_name)['predicate'] : NULL,
      ];

      $form['sparql_entity_storage']['base_fields_mapping'][$field_name][$column_name]['format'] = [
        '#type' => 'select',
        '#title' => t('Value format'),
        '#title' => t(':field_title value format', [
          ':field_title' => $column_title,
        ]),
        '#description' => t('The RDF format. Required if format is filled.'),
        '#options' => SparqlEntityStorageFieldHandler::getSupportedDataTypes(),
        '#empty_value' => '',
        '#weight' => 151,
        '#default_value' => $mapping ? $mapping->getMapping($field_name, $column_name)['format'] : NULL,
        '#default_value' => $has_mapping ? $mapping->getMapping($field_name, $column_name)['format'] : NULL,
      ];
    }
  }