public MenuLinkDefaultForm::extractFormValues(array &$form, FormStateInterface $form_state)
Extracts a plugin definition from form values.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The new plugin definition values taken from the form values. The plugin ID must be returned as part of the definition.
Overrides MenuLinkFormInterface::extractFormValues
File
- core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php, line 159
Class
- MenuLinkDefaultForm
- Provides an edit form for static menu links.
Namespace
Drupal\Core\Menu\Form
Code
public function extractFormValues(array &$form, FormStateInterface $form_state) { // Start from the complete, original, definition. $new_definition = $this->menuLink->getPluginDefinition(); // Since the ID may not be present in the definition used to construct the // plugin, add it here so it's available to any consumers of this method. $new_definition['id'] = $form_state->getValue('id'); $new_definition['enabled'] = $form_state->getValue('enabled') ? 1 : 0; $new_definition['weight'] = (int) $form_state->getValue('weight'); $new_definition['expanded'] = $form_state->getValue('expanded') ? 1 : 0; list($menu_name, $parent) = explode(':', $form_state->getValue('menu_parent'), 2); if (!empty($menu_name)) { $new_definition['menu_name'] = $menu_name; } if (isset($parent)) { $new_definition['parent'] = $parent; } return $new_definition; }
Please login to continue.