FileInlineEditForm.php in File Entity (fieldable files) 8.2
File
src/Form/FileInlineEditForm.php
View source
<?php
namespace Drupal\file_entity\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
class FileInlineEditForm extends FileEditForm {
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['#action'] = '/file/' . $this
->getEntity()
->id() . '/inline-edit';
return $form;
}
protected function actionsElement(array $form, FormStateInterface $form_state) {
$elements = parent::actionsElement($form, $form_state);
foreach (Element::children($elements) as $key) {
if ($key != 'submit') {
$elements[$key]['#access'] = FALSE;
}
}
$elements['submit']['#ajax'] = [
'url' => Url::fromRoute('entity.file.inline_edit_form', [
'file' => $this
->getEntity()
->id(),
]),
];
return $elements;
}
}