ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
base.php
Go to the documentation of this file.
1<?php
5function base()
6{
7 //Step 0: Declare dependencies
8 global $DIC;
9 $ui = $DIC->ui()->factory();
10 $renderer = $DIC->ui()->renderer();
11 $request = $DIC->http()->request();
12
13 //Step 1: Define the dependent group (aka sub section)
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 //Step 2: Define input and attach sub section
20 $checkbox_input = $ui->input()->field()->checkbox("Checkbox", "Check to display dependant field.")
21 ->withValue(true)
22 ->withDependantGroup($dependant_group);
23
24 //Step 3: Define form and form actions
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 //Step 4: Implement some form data processing.
36 if ($request->getMethod() == "POST"
37 && $request->getQueryParams()['example_name'] == 'checkbox') {
38 $form = $form->withRequest($request);
39 $result = $form->getData();
40 } else {
41 $result = "No result yet.";
42 }
43
44 //Step 5: Render the checkbox with the enclosing form.
45 return
46 "<pre>" . print_r($result, true) . "</pre><br/>" .
47 $renderer->render($form);
48}
base()
Definition: base.php:2
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7