ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
base.php
Go to the documentation of this file.
1 <?php
5 function 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 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
global $DIC
Definition: saml.php:7
base()
Definition: base.php:2
if(isset($_POST['submit'])) $form