ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
with_required_sub_inputs.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
41 {
42  global $DIC;
43  $factory = $DIC->ui()->factory();
44  $renderer = $DIC->ui()->renderer();
45  $request = $DIC->http()->request();
46 
47  $optional_group = $factory->input()->field()->optionalGroup([
48  $factory->input()->field()->text(
49  'this input is required',
50  'but only if the optional group is checked'
51  )->withRequired(true)
52  ], 'this input is not required');
53 
54  $form = $factory->input()->container()->form()->standard('#', [$optional_group]);
55 
56  if ("POST" === $request->getMethod()) {
57  $form = $form->withRequest($request);
58  $result = $form->getData();
59  } else {
60  $result = "No result yet.";
61  }
62 
63  return "<pre>" . print_r($result, true) . "</pre>" . $renderer->render($form);
64 }
$renderer
global $DIC
Definition: shib_login.php:22
with_required_sub_inputs()
description: > Example showing how an optional group (of inputs) which shows, that the optional inpu...