ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
base.php
Go to the documentation of this file.
1 <?php
5 function base()
6 {
7  //Step 1: Declare dependencies
8  global $DIC;
9  $ui = $DIC->ui()->factory();
10  $renderer = $DIC->ui()->renderer();
11  $request = $DIC->http()->request();
12 
13  //Step 2: define the radio with options
14  $radio = $ui->input()->field()->radio("Radio", "check an option")
15  ->withOption('value1', 'label1', 'byline1')
16  ->withOption('10', 'numeric value (ten)', 'byline2')
17  ->withOption('030', 'not-numeric value', 'byline3');
18 
19  //Step 3: define form and form actions
20  $form = $ui->input()->container()->form()->standard('#', ['radio' => $radio]);
21 
22  //Step 4: implement some form data processing.
23  if ($request->getMethod() == "POST") {
24  $form = $form->withRequest($request);
25  $result = $form->getData();
26  } else {
27  $result = "No result yet.";
28  }
29 
30  //Step 5: Render the radio with the enclosing form.
31  return
32  "<pre>" . print_r($result, true) . "</pre><br/>" .
33  $renderer->render($form);
34 }
$result
base()
Definition: base.php:4
$DIC
Definition: xapitoken.php:46