Change record status: 
Introduced in branch: 

Forms often need boilerplate code, such as the translation manager or an empty validateForm() method.

For example

abstract class ConfirmFormBase implements ConfirmFormInterface {

   // So other code.

    * {@inheritdoc}
   public function validateForm(array &$form, array &$form_state) {

Add FormBase to avoid this boilerplate code, now abstract class ConfirmFormBase becomes:

abstract class ConfirmFormBase extends FormBase implements ConfirmFormInterface {

No need to call validateForm again.

Oher API changes associated with form controllers:

API additions

  • \Drupal\Core\Form\FormBase is added, containing protected function t() as a helper method
  • \Drupal\Core\Entity\EntityFormControllerInterface has a public function setTranslationManager(), which is called automatically to prevent constructor changes
  • protected function getCurrentUser() to get the current user.
  • protected function public function l($text, $route_name, array $parameters = array(), array $options = array())(), which allows to provide a link using route names and parameters.
  • public function redirect($route_name, array $route_parameters = array(), $status = 302);, which allows to redirect to a specified route.
  • public function url($route_name, array $route_parameters = array(), array $options = array());, which allows to create an url using specified route name/parameters.

API changes

  • While in route based forms, the request can still be retrieved in buildForm(), it is unreliable. $this->getRequest() should be used
  • Entity forms (EntityFormControllerInterface) can no longer use EntityControllerInterface, they should be like all other forms and use ContainerInjectionInterface
  • \Drupal\image\Form\ImageStyleFormBase had its $this->translator property changed to $this->translationManager to match the rest of core
Site builders, administrators, editors
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other updates done