ILIAS  release_7 Revision v7.30-3-g800a261c036
base.php
Go to the documentation of this file.
1<?php
5function 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}
base()
Definition: base.php:4
$result
An exception for terminatinating execution or to throw for unit testing.
global $DIC
Definition: goto.php:24