Last active
September 30, 2021 13:29
-
-
Save fago/2566a9ac0ec0e48d9da94a059e913a47 to your computer and use it in GitHub Desktop.
example for rendering form for WV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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