public function FlexiformEntityFormDisplay::buildAdvancedForm in Flexiform 8
Build standalone form.
A standalone form does not have a single base. This allows the passing of a single array of provided entities.
Parameters
\Drupal\Core\Entity\FieldableEntityInterface[] $provided: An array of provided entities keyed by namespace.
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
1 call to FlexiformEntityFormDisplay::buildAdvancedForm()
- FlexiformEntityFormDisplay::buildForm in src/
FlexiformEntityFormDisplay.php - Adds field widgets to an entity form.
File
- src/
FlexiformEntityFormDisplay.php, line 289
Class
- FlexiformEntityFormDisplay
- Defines a class to extend EntityFormDisplays.
Namespace
Drupal\flexiformCode
public function buildAdvancedForm(array $provided, array &$form, FormStateInterface $form_state) {
// Set #parents to 'top-level' by default.
$form += [
'#parents' => [],
'#array_parents' => [],
];
$original_parents = $form['#parents'];
$form_state = $this
->decorateFormState($form, $form_state);
$this
->getFormEntityManager($form_state, $provided);
// Let each widget generate the form elements.
foreach ($this
->getComponents() as $name => $options) {
$component = $this
->getComponentPlugin($name, $options, $form_state
->getFormEntityManager());
// On each component reset the parents back to the original.
$form['#parents'] = $original_parents;
$component
->render($form, $form_state, $this->renderer);
}
// Set form parents back to the original.
$form['#parents'] = $original_parents;
// Associate the cache tags for the form display.
$this->renderer
->addCacheableDependency($form, $this);
// Add a process callback so we can assign weights and hide extra fields.
$form['#process'][] = [
$this,
'processForm',
];
}