Example showing how a dependant group (aka sub form) might be attached to a checkbox.
6{
7
9 $ui =
$DIC->ui()->factory();
10 $renderer =
$DIC->ui()->renderer();
12
13
14 $dependant_field1 = $ui->input()->field()->text("Item 1", "Just some dependent group field");
15 $dependant_field2 = $ui->input()->field()->text("Item 1", "Just another dependent group field");
16
17 $dependant_group = $ui->input()->field()->dependantGroup([ "Sub Part 1" => $dependant_field1, "Sub Part 2" => $dependant_field2]);
18
19
20 $checkbox_input = $ui->input()->field()->checkbox("Checkbox", "Check to display dependant field.")
21 ->withValue(true)
22 ->withDependantGroup($dependant_group);
23
24
25 $DIC->ctrl()->setParameterByClass(
26 'ilsystemstyledocumentationgui',
27 'example_name',
28 'checkbox'
29 );
30
31 $form_action =
$DIC->ctrl()->getFormActionByClass(
'ilsystemstyledocumentationgui');
32 $form = $ui->input()->container()->form()->standard($form_action, [
"checkbox" => $checkbox_input]);
33
34
35
37 &&
$request->getQueryParams()[
'example_name'] ==
'checkbox') {
40 } else {
42 }
43
44
45 return
46 "<pre>" . print_r(
$result,
true) .
"</pre><br/>" .
47 $renderer->render(
$form);
48}
foreach($paths as $path) $request
if(isset($_POST['submit'])) $form