You are here

public static function ContentMappings::alterForm in Schema.org configuration tool (RDF UI) 8

BuildForm method for the Schema.org mappings in \Drupal\node\NodeTypeForm.

See also

formValidate()

submitForm()

2 calls to ContentMappings::alterForm()
rdfui_form_node_type_add_form_alter in ./rdfui.module
Implements hook_form_FORM_ID_alter().
rdfui_form_node_type_edit_form_alter in ./rdfui.module
Implements hook_form_FORM_ID_alter().

File

src/ContentMappings.php, line 19

Class

ContentMappings
RDF UI Rdf Mapping for Content Types.

Namespace

Drupal\rdfui

Code

public static function alterForm(array &$form, FormStateInterface $form_state) {
  $type_options = new SchemaOrgConverter();
  $entity_type = $form_state
    ->getFormObject()
    ->getEntity();
  $existing_type = '';
  if (!$entity_type
    ->isNew()) {
    $existing_type = rdf_get_mapping('node', $entity_type
      ->id())
      ->getBundleMapping();
  }
  $form['rdf-mapping'] = array(
    '#type' => 'details',
    '#title' => t('Schema.org Mappings'),
    '#group' => 'additional_settings',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['rdf-mapping']['types'] = array(
    '#id' => 'rdf-predicate',
    '#type' => 'select',
    '#title' => t('Schema.org Type'),
    '#options' => $type_options
      ->getListTypes(),
    '#empty_option' => '',
    '#attached' => array(
      'library' => array(
        'rdfui/drupal.rdfui.autocomplete',
      ),
    ),
    '#default_value' => !empty($existing_type) ? $existing_type['types'][0] : '',
    '#description' => t('Specify the type you want to associated to this content type e.g. Article, Blog, etc.'),
  );
  return $form;
}