You are here

public function MultipleNodeExportForm::buildForm in Node export 8

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 FormInterface::buildForm

File

src/Form/MultipleNodeExportForm.php, line 23

Class

MultipleNodeExportForm
Provides a Node Export form.

Namespace

Drupal\node_Export\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Loads all the content typess in the drupal site.
  $contentTypes = \Drupal::service('entity_type.manager')
    ->getStorage('node_type')
    ->loadMultiple();
  $contentTypesList = [];
  foreach ($contentTypes as $contentType) {
    $contentTypesList[$contentType
      ->id()] = $contentType
      ->label();
  }
  $form['ct'] = [
    '#markup' => $this
      ->t('Select the content type of the node you want to export : '),
  ];
  $form['export_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Select Type'),
    '#options' => $contentTypesList,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Export'),
  ];
  return $form;
}