public function WebformTestElementController::index in Webform 8.5
Same name and namespace in other branches
- 6.x tests/modules/webform_test_element/src/Controller/WebformTestElementController.php \Drupal\webform_test_element\Controller\WebformTestElementController::index()
Returns the webform test element page.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The current request.
Return value
array A render array containing a webform.
File
- tests/
modules/ webform_test_element/ src/ Controller/ WebformTestElementController.php, line 22
Class
- WebformTestElementController
- Provides route responses for webform test element.
Namespace
Drupal\webform_test_element\ControllerCode
public function index(Request $request) {
$build = [];
// Render the contact form.
$build['webform'] = [
'#type' => 'webform',
'#webform' => 'contact',
];
// Populate webform properties using query string parameters.
$properties = [
'sid',
'default_data',
'information',
'action',
];
foreach ($properties as $property) {
if ($value = $request->query
->get($property)) {
switch ($value) {
case 'false':
$value = FALSE;
break;
}
$build['webform']["#{$property}"] = $value;
}
}
return $build;
}