You are here

protected function FileInlineEditForm::actionsElement in File Entity (fieldable files) 8.2

Returns the action form element for the current entity form.

Overrides EntityForm::actionsElement

File

src/Form/FileInlineEditForm.php, line 27

Class

FileInlineEditForm
Form class for inline edit form.

Namespace

Drupal\file_entity\Form

Code

protected function actionsElement(array $form, FormStateInterface $form_state) {
  $elements = parent::actionsElement($form, $form_state);

  // Let's allow the save button only.
  foreach (Element::children($elements) as $key) {
    if ($key != 'submit') {
      $elements[$key]['#access'] = FALSE;
    }
  }

  // Use Ajax.
  $elements['submit']['#ajax'] = [
    'url' => Url::fromRoute('entity.file.inline_edit_form', [
      'file' => $this
        ->getEntity()
        ->id(),
    ]),
  ];
  return $elements;
}