You are here

public function FieldCollectionItemForm::form in Field collection 8.3

Same name and namespace in other branches
  1. 8 src/FieldCollectionItemForm.php \Drupal\field_collection\FieldCollectionItemForm::form()

Gets the actual form array to be built.

Overrides ContentEntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

src/FieldCollectionItemForm.php, line 13

Class

FieldCollectionItemForm

Namespace

Drupal\field_collection

Code

public function form(array $form, FormStateInterface $form_state) {
  $field_collection_item = $this->entity;
  if ($this->operation == 'edit') {
    $form['#title'] = $this
      ->t('<em>Edit @type</em>', [
      '@type' => $field_collection_item
        ->label(),
    ]);
  }

  /*
  // Basic item information.
  foreach (['revision_id', 'id', 'field_name'] as $key) {
    $form[$key] = [
      '#type' => 'value',
      '#value' => $field_collection_item->$key->value,
    ];
  }

  $language_configuration = module_invoke('language', 'get_default_configuration', 'field_collection_item', $field_collection_item->field_name->value);

  // Set the correct default language.
  if ($field_collection_item->isNew() && !empty($language_configuration['langcode'])) {
    $language_default = language($language_configuration['langcode']);
    $field_collection_item->langcode->value = $language_default->langcode;
  }

  $form['langcode'] = [
    '#title' => t('Language'),
    '#type' => 'language_select',
    '#default_value' => $field_collection_item->langcode->value,
    '#languages' => LANGUAGE_ALL,
    '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'],
  ];
  */
  return parent::form($form, $form_state);
}