You are here

public function GroupAddForm::buildForm in Paragraphs Browser 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 EntityForm::buildForm

File

src/Form/GroupAddForm.php, line 84
Contains \Drupal\paragraphs_browser\Form\GroupAddForm.

Class

GroupAddForm
Class GroupAddForm.

Namespace

Drupal\paragraphs_browser\Form

Code

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

  // Build the form.
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => '',
    '#required' => TRUE,
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#title' => $this
      ->t('Machine name'),
    '#default_value' => '',
    '#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".',
    ),
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => $this
      ->t('Add'),
    '#button_type' => 'primary',
    '#submit' => array(
      '::submitForm',
      '::save',
    ),
  );
  return $form;
}