ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
nested.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
17 function nested()
18 {
19  // Step 0: Declare dependencies
20  global $DIC;
21  $ui = $DIC->ui()->factory();
22  $renderer = $DIC->ui()->renderer();
23 
24  // Step 1: Define inputs for the innermost section
25  $text_input = $ui->input()->field()->text("Text Input", "Enter some text here.");
26  $multi_select = $ui->input()->field()->multiselect(
27  "Multi-Select",
28  [
29  "1" => "Option 1",
30  "2" => "Option 2",
31  "3" => "Option 3",
32  ],
33  "Choose one or more options"
34  );
35 
36  $inner_section = $ui->input()->field()->section(
37  [$text_input, $multi_select],
38  "Inner Section",
39  "This is the innermost section."
40  )->withRequired(true);
41 
42  // Step 2: Define inputs for the middle section
43  $dropdown = $ui->input()->field()->select(
44  "Dropdown",
45  [
46  "1" => "Choice 1",
47  "2" => "Choice 2",
48  "3" => "Choice 3",
49  ],
50  "Select a single choice"
51  );
52 
53  $middle_section = $ui->input()->field()->section(
54  [$dropdown, $inner_section],
55  "Middle Section",
56  "This section contains the inner section and a dropdown."
57  );
58 
59  // Step 3: Define the outer section
60  $number_input = $ui->input()->field()->numeric("Numeric Input", "Enter a number.");
61  $outer_section = $ui->input()->field()->section(
62  [$number_input, $middle_section],
63  "Outer Section",
64  "This is the top-level section containing all other sections."
65  );
66 
67  // Step 4: Define the form and attach the outer section
68  $form = $ui->input()->container()->form()->standard("#", [$outer_section]);
69 
70  // Step 5: Render the form (no submission or processing, purely for display)
71  return $renderer->render($form);
72 }
$renderer
global $DIC
Definition: shib_login.php:22
nested()
description: > Example showing how sections can be nested inside one another.
Definition: nested.php:17