You are here

public function ImportEntityForm::buildForm in Content Synchronizer 3.x

Same name and namespace in other branches
  1. 8.2 src/Form/ImportEntityForm.php \Drupal\content_synchronizer\Form\ImportEntityForm::buildForm()
  2. 8 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 50

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() : $this
    ->t('Import - %date', [
    '%date' => $this->dateFormatter
      ->format(time()),
  ]);
  $form['name']['widget'][0]['value']['#default_value'] = $defaultName;
  return $form;
}