FilebrowserFormController.php in Filebrowser 8
Definition of Drupal\foo_bar\Entity\Form\FooBarFormController.
Namespace
Drupal\filebrowser\Entity\FormFile
lib/Drupal/filebrowser/Entity/Form/FilebrowserFormController.phpView source
<?php
/**
* @file
* Definition of Drupal\foo_bar\Entity\Form\FooBarFormController.
*/
namespace Drupal\filebrowser\Entity\Form;
use Drupal\Core\Entity\ContentEntityFormController;
use Drupal\Core\Language\Language;
/**
* Form controller for the filebrowser entity edit forms.
* Define the form for adding and editing entity content.
* It is called by the '_entity_form' definition in the routing.
*/
class FilebrowserFormController extends ContentEntityFormController {
// Overrides Drupal\Core\Entity\EntityFormController::form().
public function form(array $form, array &$form_state) {
/* @var $entity \Drupal\filebrowser\Entity\Filebrowser */
$form = parent::form($form, $form_state);
$entity = $this->entity;
$form['user_id'] = array(
'#type' => 'textfield',
'#title' => 'UID',
'#default_value' => $entity->user_id->target_id,
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
'#weight' => -10,
);
$form['langcode'] = array(
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity
->getUntranslated()
->language()->id,
'#languages' => Language::STATE_ALL,
);
return $form;
}
// Overrides \Drupal\Core\Entity\EntityFormController::submit().
public function submit(array $form, array &$form_state) {
// Build the entity object from the submitted values.
$entity = parent::submit($form, $form_state);
$form_state['redirect_route']['route_name'] = 'filebrowser.list';
return $entity;
}
// Overrides Drupal\Core\Entity\EntityFormController::save().
public function save(array $form, array &$form_state) {
$entity = $this->entity;
$entity
->save();
}
}
Classes
Name | Description |
---|---|
FilebrowserFormController | Form controller for the filebrowser entity edit forms. Define the form for adding and editing entity content. It is called by the '_entity_form' definition in the routing. |