ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
base.php File Reference

Go to the source code of this file.

Functions

 base ()
 Base example showing how to plug a checkbox into a form. More...
 

Function Documentation

◆ base()

base ( )

Base example showing how to plug a checkbox into a form.

Definition at line 5 of file base.php.

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 checkbox, and turning it on
14 $checkbox_input = $ui->input()->field()->checkbox("Checkbox", "Check or not.")
15 ->withValue('checked');
16
17 //Step 2: define form and form actions
18 $DIC->ctrl()->setParameterByClass(
19 'ilsystemstyledocumentationgui',
20 'example_name',
21 'base_checkbox'
22 );
23 $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
24 $form = $ui->input()->container()->form()->standard($form_action, [ $checkbox_input]);
25
26 //Step 3: implement some form data processing. Note, the value of the checkbox will
27 // be 'checked' if checked an null if unchecked.
28 if ($request->getMethod() == "POST"
29 && $request->getQueryParams()['example_name'] == 'base_checkbox') {
30 $form = $form->withRequest($request);
31 $result = $form->getData();
32 } else {
33 $result = "No result yet.";
34 }
35
36 //Step 4: Render the checkbox with the enclosing form.
37 return
38 "<pre>" . print_r($result, true) . "</pre><br/>" .
39 $renderer->render($form);
40}
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7

References $DIC, $form, $request, and $result.