You are here

public function FooTableBreakpointEditForm::buildForm in FooTable 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/FooTableBreakpointEditForm.php, line 18

Class

FooTableBreakpointEditForm
Edit form for FooTable Breakpoints.

Namespace

Drupal\footable\Form

Code

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

  /** @var FooTableBreakpoint $breakpoint */
  $breakpoint = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $breakpoint
      ->label(),
    '#required' => TRUE,
  ];
  $form['name'] = [
    '#type' => 'machine_name',
    '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
    '#machine_name' => [
      'exists' => '\\Drupal\\footable\\Entity\\FooTableBreakpoint::load',
    ],
    '#default_value' => $breakpoint
      ->id(),
    '#disabled' => !$breakpoint
      ->isNew(),
    '#required' => TRUE,
  ];
  $form['breakpoint'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Breakpoint'),
    '#min' => 1,
    '#field_suffix' => 'px',
    '#default_value' => $breakpoint
      ->getBreakpoint(),
    '#required' => TRUE,
  ];
  return $form;
}