public function FormModeManager::setFormClassPerFormModes in Form mode manager 8
Same name and namespace in other branches
- 8.2 src/FormModeManager.php \Drupal\form_mode_manager\FormModeManager::setFormClassPerFormModes()
Set new FormClass handler per form modes keyed by form mode name.
This setter are the best way to alter the basic FormClass, for specific operation (form mode)
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_definition: The entity type to alter.
string $form_mode_name: The form mode human name used by current entity definition.
Overrides FormModeManagerInterface::setFormClassPerFormModes
See also
1 call to FormModeManager::setFormClassPerFormModes()
- FormModeManager::setEntityHandlersPerFormModes in src/
FormModeManager.php - Set all entity handlers needed by form mode manager on entity type basis.
File
- src/
FormModeManager.php, line 307
Class
- FormModeManager
- FormDisplayManager service.
Namespace
Drupal\form_mode_managerCode
public function setFormClassPerFormModes(EntityTypeInterface $entity_definition, $form_mode_name) {
$entity_type_id = $entity_definition
->id();
/** @var \Drupal\form_mode_manager\EntityRoutingMapBase $route_mapper_plugin */
$route_mapper_plugin = $this->entityRoutingMap
->createInstance($entity_type_id, [
'entityTypeId' => $entity_type_id,
]);
if ($default_form = $entity_definition
->getFormClass($route_mapper_plugin
->getDefaultFormClass())) {
$entity_definition
->setFormClass($form_mode_name, $default_form);
}
if ($edit_form = $entity_definition
->getFormClass($route_mapper_plugin
->getEditFormClass())) {
$entity_definition
->setFormClass('edit_' . $form_mode_name, $edit_form);
}
}