ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
with_required_sub_inputs.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
25 {
26  global $DIC;
27  $factory = $DIC->ui()->factory();
28  $renderer = $DIC->ui()->renderer();
29  $request = $DIC->http()->request();
30 
31  $optional_group = $factory->input()->field()->optionalGroup([
32  $factory->input()->field()->text(
33  'this input is required',
34  'but only if the optional group is checked'
35  )->withRequired(true)
36  ], 'this input is not required');
37 
38  $form = $factory->input()->container()->form()->standard('#', [$optional_group]);
39 
40  if ("POST" === $request->getMethod()) {
41  $form = $form->withRequest($request);
42  $result = $form->getData();
43  } else {
44  $result = "No result yet.";
45  }
46 
47  return "<pre>" . print_r($result, true) . "</pre>" . $renderer->render($form);
48 }
$renderer
global $DIC
Definition: shib_login.php:25
with_required_sub_inputs()
description: > Example showing how an optional group (of inputs) which shows, that the optional inpu...