ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
base.php File Reference

Go to the source code of this file.

Functions

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

Function Documentation

◆ base()

base ( )

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

Definition at line 5 of file base.php.

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
$DIC
Definition: xapitoken.php:46

References $DIC, and $result.