You are here

public function MigrationGroupFormBase::buildForm in Migrate Tools 8

Same name and namespace in other branches
  1. 8.5 src/Form/MigrationGroupFormBase.php \Drupal\migrate_tools\Form\MigrationGroupFormBase::buildForm()
  2. 8.2 src/Form/MigrationGroupFormBase.php \Drupal\migrate_tools\Form\MigrationGroupFormBase::buildForm()
  3. 8.3 src/Form/MigrationGroupFormBase.php \Drupal\migrate_tools\Form\MigrationGroupFormBase::buildForm()
  4. 8.4 src/Form/MigrationGroupFormBase.php \Drupal\migrate_tools\Form\MigrationGroupFormBase::buildForm()

Overrides Drupal\Core\Entity\EntityFormController::form().

Builds the entity add/edit form.

Parameters

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

\Drupal\Core\Form\FormStateInterface $form_state: An associative array containing the current state of the form.

Return value

array An associative array containing the migration group add/edit form.

Overrides EntityForm::buildForm

File

src/Form/MigrationGroupFormBase.php, line 71
Contains Drupal\migrate_tools\Form\MigrationGroupFormBase.

Class

MigrationGroupFormBase
Class MigrationGroupFormBase.

Namespace

Drupal\migrate_tools\Form

Code

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

  // Get anything we need from the base class.
  $form = parent::buildForm($form, $form_state);

  /** @var MigrationGroupInterface $migration_group */
  $migration_group = $this->entity;

  // Build the form.
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $migration_group
      ->label(),
    '#required' => TRUE,
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#title' => $this
      ->t('Machine name'),
    '#default_value' => $migration_group
      ->id(),
    '#machine_name' => array(
      'exists' => array(
        $this,
        'exists',
      ),
      'replace_pattern' => '([^a-z0-9_]+)|(^custom$)',
      'error' => 'The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".',
    ),
    '#disabled' => !$migration_group
      ->isNew(),
  );
  $form['description'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Description'),
    '#maxlength' => 255,
    '#default_value' => $migration_group
      ->get('description'),
  );
  $form['source_type'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Source type'),
    '#description' => $this
      ->t('Type of source system the group is migrating from, for example "Drupal 6" or "WordPress 4".'),
    '#maxlength' => 255,
    '#default_value' => $migration_group
      ->get('source_type'),
  );

  // Return the form.
  return $form;
}