You are here

protected function ConfigPagesForm::actions in Config Pages 8.2

Same name and namespace in other branches
  1. 8.3 src/ConfigPagesForm.php \Drupal\config_pages\ConfigPagesForm::actions()
  2. 8 src/ConfigPagesForm.php \Drupal\config_pages\ConfigPagesForm::actions()

Returns an array of supported actions for the current entity form.

@todo Consider introducing a 'preview' action here, since it is used by many entity types.

Parameters

array $form: Form.

\Drupal\Core\Form\FormStateInterface $form_state: Form state.

Return value

array Array of actions.

Overrides EntityForm::actions

File

src/ConfigPagesForm.php, line 354

Class

ConfigPagesForm
Form controller for the custom config page edit forms.

Namespace

Drupal\config_pages

Code

protected function actions(array $form, FormStateInterface $form_state) {
  $entity = $this->entity;

  // Save ConfigPage entity.
  $actions['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
    '#submit' => [
      '::submitForm',
      '::save',
    ],
  ];
  if (!$entity
    ->isNew()) {

    // Add button to reset values.
    $actions['reset'] = [
      '#type' => 'submit',
      '#value' => t('Clear values'),
      '#submit' => [
        '::configPagesClearValues',
      ],
      '#button_type' => "submit",
      '#access' => $this->user
        ->hasPermission('administer config_pages entity'),
    ];
  }
  return $actions;
}