Skip to content

Instantly share code, notes, and snippets.

@fago
Last active September 30, 2021 13:29
Show Gist options
  • Save fago/2566a9ac0ec0e48d9da94a059e913a47 to your computer and use it in GitHub Desktop.
Save fago/2566a9ac0ec0e48d9da94a059e913a47 to your computer and use it in GitHub Desktop.
example for rendering form for WV
class CustomElementsFormController extends HtmlFormController {
/**
* {@inheritDoc}
*/
public function getContentResult(Request $request, RouteMatchInterface $route_match) {
$form = parent::getContentResult($request, $route_match);
return $this->getCustomElementsContentResult($form);
}
/**
* Prepare the content result wrapped in custom elements.
*
* @param array $form
* The prepared and processed form render array.
*
* @return \Drupal\custom_elements\CustomElement
* The lupus-form custom element.
*/
public function getCustomElementsContentResult(array $form): CustomElement {
return CustomElement::createFromRenderArray($form);
}
}
/**
Example route definition:
route.example.form:
path: '...'
defaults:
_controller: '...\CustomElementsFormController::getContentResult'
requirements:
_permission: 'access content'
_format: 'custom_elements'
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment