You are here

public function ImportEntityForm::buildForm in Content Synchronizer 8

Same name and namespace in other branches
  1. 8.2 src/Form/ImportEntityForm.php \Drupal\content_synchronizer\Form\ImportEntityForm::buildForm()
  2. 3.x src/Form/ImportEntityForm.php \Drupal\content_synchronizer\Form\ImportEntityForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides EntityForm::buildForm

File

src/Form/ImportEntityForm.php, line 18

Class

ImportEntityForm
Form controller for Import edit forms.

Namespace

Drupal\content_synchronizer\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);

  /* @var $entity \Drupal\content_synchronizer\Entity\ImportEntity */
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  $defaultName = $entity ? $entity
    ->label() : t('Import - %date', [
    '%date' => \Drupal::service('date.formatter')
      ->format(time()),
  ]);
  $form['name']['widget'][0]['value']['#default_value'] = $defaultName;
  return $form;
}