ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
with_required_sub_inputs.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
13 {
14  global $DIC;
15  $factory = $DIC->ui()->factory();
16  $renderer = $DIC->ui()->renderer();
17  $request = $DIC->http()->request();
18 
19  $optional_group = $factory->input()->field()->optionalGroup([
20  $factory->input()->field()->text(
21  'this input is required',
22  'but only if the optional group is checked'
23  )->withRequired(true)
24  ], 'this input is not required');
25 
26  $form = $factory->input()->container()->form()->standard('#', [$optional_group]);
27 
28  if ("POST" === $request->getMethod()) {
29  $form = $form->withRequest($request);
30  $result = $form->getData();
31  } else {
32  $result = "No result yet.";
33  }
34 
35  return "<pre>" . print_r($result, true) . "</pre>" . $renderer->render($form);
36 }
global $DIC
Definition: feed.php:28
with_required_sub_inputs()
Example showing how an optional group (of inputs) which shows, that the optional input will not be re...
$factory
Definition: metadata.php:75