public function ForwardFormBuilder::buildForwardEntityForm in Forward 8
Same name and namespace in other branches
- 8.3 src/ForwardFormBuilder.php \Drupal\forward\ForwardFormBuilder::buildForwardEntityForm()
- 8.2 src/ForwardFormBuilder.php \Drupal\forward\ForwardFormBuilder::buildForwardEntityForm()
Builds a Forward inline form for a given entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: Entity for which the form is being built.
array $settings: Array of settings.
Return value
array A render array for the form.
Overrides ForwardFormBuilderInterface::buildForwardEntityForm
File
- src/
ForwardFormBuilder.php, line 176
Class
- ForwardFormBuilder
- Defines a class for building markup for a Forward inline form on an entity.
Namespace
Drupal\forwardCode
public function buildForwardEntityForm(EntityInterface $entity, array $settings) {
// The entity must be injected first, since it is used to compute the form ID.
$form = new ForwardForm($entity);
// Now inject the services.
$form
->injectServices($this->moduleHandler, $this->entityTypeManager, $this->requestStack, $this->database, $this->tokenService, $this->floodInterface, $this->accountSwitcher, $this->renderer, $this->eventDispatcher, $this->mailer, $this->linkGenerator);
$render_array = $this->formBuilder
->getForm($form, $settings);
$render_array['#weight'] = $settings['forward_interface_weight'];
return $render_array;
}