class FlexiformEntityFormDisplayEditForm in Flexiform 8
Provides Flexiform form elements for the EntityFormDisplay entity type.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Entity\EntityForm implements EntityFormInterface
- class \Drupal\field_ui\Form\EntityDisplayFormBase
- class \Drupal\field_ui\Form\EntityFormDisplayEditForm
- class \Drupal\flexiform\Form\FlexiformEntityFormDisplayEditForm uses AjaxFormTrait
- class \Drupal\field_ui\Form\EntityFormDisplayEditForm
- class \Drupal\field_ui\Form\EntityDisplayFormBase
- class \Drupal\Core\Entity\EntityForm implements EntityFormInterface
Expanded class hierarchy of FlexiformEntityFormDisplayEditForm
File
- src/
Form/ FlexiformEntityFormDisplayEditForm.php, line 16
Namespace
Drupal\flexiform\FormView source
class FlexiformEntityFormDisplayEditForm extends EntityFormDisplayEditForm {
use AjaxFormTrait;
/**
* The form entity manager object.
*
* @var \Drupal\flexiform\FormEntity\FlexiformFormEntityManager
*/
protected $formEntityManager;
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
if (!isset($form['#parents'])) {
$form['#parents'] = [];
}
$form_state = MultipleEntityFormState::createForForm($form, $form_state);
$form = parent::form($form, $form_state);
$form['#entity_type'] = $this->entity
->getTargetEntityTypeId();
$form['#bundle'] = $this->entity
->getTargetBundle();
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
$form['#attached']['library'][] = 'core/drupal.ajax';
$form['fields']['#header'][0] = $this
->t('Component');
// Components.
$component_type_manager = \Drupal::service('plugin.manager.flexiform.form_component_type');
$component_rows = [];
foreach ($component_type_manager
->getDefinitions() as $component_type => $definition) {
$component_rows += $component_type_manager
->createInstance($component_type)
->setFormDisplay($this->entity)
->setFormEntityManager($this->entity
->getFormEntityManager($form_state))
->componentRows($this, $form, $form_state);
}
$form['fields'] = $component_rows + $form['fields'];
// Enhancers.
$form['enhancer'] = [
'#type' => 'vertical_tabs',
];
foreach ($this->entity
->getFormEnhancers('configuration_form') as $enhancer_name => $enhancer) {
if ($enhancer instanceof ConfigurableFormEnhancerInterface) {
$form['enhancer_' . $enhancer_name] = [
'#type' => 'details',
'#title' => $enhancer
->getPluginDefinition()['label'],
'#parents' => [
'enhancer',
$enhancer_name,
],
'#array_parents' => [
'enhancer_' . $enhancer_name,
],
'#group' => 'enhancer',
'#tree' => TRUE,
];
$form['enhancer_' . $enhancer_name] += $enhancer
->configurationForm($form['enhancer_' . $enhancer_name], $form_state);
}
}
if (!empty($form['modes'])) {
$form['modes']['#weight'] = 90;
}
return $form;
}
/**
* {@inheritdoc}
*/
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
$form_state = MultipleEntityFormState::createForForm($form, $form_state);
$form_values = $form_state
->getValues();
if ($this->entity instanceof EntityWithPluginCollectionInterface) {
// Do not manually update values represented by plugin collections.
$form_values = array_diff_key($form_values, $this->entity
->getPluginCollections());
}
// Collect component options.
foreach ($form_values['fields'] as $component_name => $values) {
// Do not handle extra fields here.
// @todo: Make extra fields a component type.
if (!empty($form['#extra'][$component_name])) {
continue;
}
if ($values['region'] == 'hidden') {
$entity
->removeComponent($component_name);
}
else {
$options = $entity
->getComponent($component_name);
$options = $entity
->getComponentTypePlugin(!empty($options['component_type']) ? $options['component_type'] : 'field_widget', $this->entity
->getFormEntityManager($form_state))
->submitComponentRow($component_name, $values, $form, $form_state);
$entity
->setComponent($component_name, $options);
}
}
// Collect options for extra field components.
foreach ($form['#extra'] as $name) {
if ($form_values['fields'][$name]['region'] == 'hidden') {
$entity
->removeComponent($name);
}
else {
$entity
->setComponent($name, [
'weight' => $form_values['fields'][$name]['weight'],
'region' => $form_values['fields'][$name]['region'],
]);
}
}
// Loop over the enhancers and let them set their configuration internally
// this then gets saved in the presave of the FormDisplay entity.
foreach ($entity
->getFormEnhancers('configuration_form') as $enhancer_name => $enhancer) {
if ($enhancer instanceof ConfigurableFormEnhancerInterface) {
$enhancer
->configurationFormSubmit($form['enhancer_' . $enhancer_name], $form_state);
}
}
}
/**
* Get the form entity manager.
*
* @return \Drupal\flexiform\FormEntity\FlexiformFormEntityManager
* The entity form manager.
*/
public function getFormEntityManager() {
if (empty($this->formEntityManager)) {
$this->formEntityManager = $this->entity
->getFormEntityManager();
}
return $this->formEntityManager;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AjaxFormTrait:: |
public static | function | Gets attributes for use with an AJAX modal. | |
AjaxFormTrait:: |
public static | function | Gets attributes for use with an add button AJAX modal. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EntityDisplayFormBase:: |
protected | property |
The entity being used by this form. Overrides EntityForm:: |
|
EntityDisplayFormBase:: |
protected | property | The entity display repository. | |
EntityDisplayFormBase:: |
protected | property | The entity field manager. | |
EntityDisplayFormBase:: |
protected | property | A list of field types. | |
EntityDisplayFormBase:: |
protected | property | The widget or formatter plugin manager. | |
EntityDisplayFormBase:: |
protected | function | Builds the table row structure for a single extra field. | |
EntityDisplayFormBase:: |
protected | function | Returns an array of applicable widget or formatter options for a field. | |
EntityDisplayFormBase:: |
protected | function | Returns entity (form) displays for the current entity display type. | |
EntityDisplayFormBase:: |
protected | function | Returns form or view modes statuses for the bundle used by this form. | |
EntityDisplayFormBase:: |
public | function |
Determines which entity will be used by this form from a RouteMatch object. Overrides EntityForm:: |
|
EntityDisplayFormBase:: |
protected | function | Returns the extra fields of the entity type and bundle used by this form. | |
EntityDisplayFormBase:: |
protected | function | Collects the definitions of fields whose display is configurable. | |
EntityDisplayFormBase:: |
public | function | Returns an associative array of all regions. | |
EntityDisplayFormBase:: |
public | function | Get the regions needed to create the overview form. | |
EntityDisplayFormBase:: |
public | function | Returns the region to which a row in the display overview belongs. | |
EntityDisplayFormBase:: |
public | function | Ajax handler for multistep buttons. | |
EntityDisplayFormBase:: |
public | function | Form submission handler for multistep buttons. | |
EntityDisplayFormBase:: |
public | function | Determines the rendering order of an array representing a tree. | |
EntityDisplayFormBase:: |
protected | function | Saves the updated display mode statuses. | |
EntityDisplayFormBase:: |
public | function |
This is the default entity object builder function. It is called before any
other submit handler to build the new entity object to be used by the
following submit handlers. At this point of the form workflow the entity is
validated and the form state… Overrides EntityForm:: |
|
EntityDisplayFormBase:: |
public | function | Performs pre-render tasks on field_ui_table elements. | |
EntityDisplayFormBase:: |
public | function | Constructs a new EntityDisplayFormBase. | |
EntityForm:: |
protected | property | The entity type manager. | 3 |
EntityForm:: |
protected | property | The module handler service. | |
EntityForm:: |
protected | property | The name of the current operation. | |
EntityForm:: |
private | property | The entity manager. | |
EntityForm:: |
protected | function | Returns an array of supported actions for the current entity form. | 29 |
EntityForm:: |
protected | function | Returns the action form element for the current entity form. | |
EntityForm:: |
public | function | Form element #after_build callback: Updates the entity with submitted data. | |
EntityForm:: |
public | function |
Builds an updated entity object based upon the submitted form values. Overrides EntityFormInterface:: |
2 |
EntityForm:: |
public | function |
Form constructor. Overrides FormInterface:: |
10 |
EntityForm:: |
public | function |
Returns a string identifying the base form. Overrides BaseFormIdInterface:: |
5 |
EntityForm:: |
public | function |
Gets the form entity. Overrides EntityFormInterface:: |
|
EntityForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
10 |
EntityForm:: |
public | function |
Gets the operation identifying the form. Overrides EntityFormInterface:: |
|
EntityForm:: |
protected | function | Initialize the form state and the entity before the first form build. | 3 |
EntityForm:: |
protected | function | Prepares the entity object before the form is built first. | 3 |
EntityForm:: |
protected | function | Invokes the specified prepare hook variant. | |
EntityForm:: |
public | function | Process callback: assigns weights and hides extra fields. | |
EntityForm:: |
public | function |
Form submission handler for the 'save' action. Overrides EntityFormInterface:: |
41 |
EntityForm:: |
public | function |
Sets the form entity. Overrides EntityFormInterface:: |
|
EntityForm:: |
public | function |
Sets the entity manager for this form. Overrides EntityFormInterface:: |
|
EntityForm:: |
public | function |
Sets the entity type manager for this form. Overrides EntityFormInterface:: |
|
EntityForm:: |
public | function |
Sets the module handler for this form. Overrides EntityFormInterface:: |
|
EntityForm:: |
public | function |
Sets the operation for this form. Overrides EntityFormInterface:: |
|
EntityForm:: |
public | function | ||
EntityForm:: |
public | function | ||
EntityFormDisplayEditForm:: |
protected | property |
The display context. Either 'view' or 'form'. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Alters the widget or formatter settings summary. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Builds the table row structure for a single field. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Returns the ID of the default widget or formatter plugin for a field type. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Returns an array of form or view mode options. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Returns the form or view modes used by this form. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Returns a link to the form or view mode admin page. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Returns an entity display object to be used by this form. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Returns the Url object for a specific entity (form) display edit form. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Returns an array containing the table headers. Overrides EntityDisplayFormBase:: |
|
EntityFormDisplayEditForm:: |
protected | function |
Adds the widget or formatter third party settings forms. Overrides EntityDisplayFormBase:: |
|
FlexiformEntityFormDisplayEditForm:: |
protected | property | The form entity manager object. | |
FlexiformEntityFormDisplayEditForm:: |
protected | function |
Copies top-level form values to entity properties Overrides EntityDisplayFormBase:: |
|
FlexiformEntityFormDisplayEditForm:: |
public | function |
Gets the actual form array to be built. Overrides EntityDisplayFormBase:: |
|
FlexiformEntityFormDisplayEditForm:: |
public | function | Get the form entity manager. | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Retrieves a configuration object. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |