public function FlexiformEntityFormDisplay::extractFormValues in Flexiform 8
Extracts field values from the submitted widget values into the entity.
This accounts for drag-and-drop reordering of field values, and filtering of empty values.
Parameters
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity.
array $form: The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Return value
array An array whose keys and values are the keys of the top-level entries in $form_state->getValues() that have been processed. The remaining entries, if any, do not correspond to widgets and should be extracted manually by the caller if needed.
Overrides EntityFormDisplay::extractFormValues
File
- src/
FlexiformEntityFormDisplay.php, line 336
Class
- FlexiformEntityFormDisplay
- Defines a class to extend EntityFormDisplays.
Namespace
Drupal\flexiformCode
public function extractFormValues(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) {
// Make sure the form entity manager is appropriately constructed.
$extracted = [];
$form_state = $this
->decorateFormState($form, $form_state);
$this
->getFormEntityManager($form_state, $this
->getProvidedEntities($form_state, $entity), TRUE);
foreach ($this
->getComponents() as $name => $options) {
if (($component = $this
->getComponentPlugin($name, $options, $form_state
->getFormEntityManager())) && !empty($form[$name])) {
$component
->extractFormValues($form[$name], $form_state);
$extracted[$name] = $name;
}
}
return $extracted;
}