ILIAS  release_8 Revision v8.24
base.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
10function base()
11{
12 //Step 1: Declare dependencies
13 global $DIC;
14 $ui = $DIC->ui()->factory();
15 $renderer = $DIC->ui()->renderer();
16 $request = $DIC->http()->request();
17
18 //Step 2: define the radio with options
19 $radio = $ui->input()->field()->radio("Radio", "check an option")
20 ->withOption('value1', 'label1', 'byline1')
21 ->withOption('10', 'numeric value (ten)', 'byline2')
22 ->withOption('030', 'not-numeric value', 'byline3');
23
24 //Step 3: define form and form actions
25 $form = $ui->input()->container()->form()->standard('#', ['radio' => $radio]);
26
27 //Step 4: implement some form data processing.
28 if ($request->getMethod() == "POST") {
29 $form = $form->withRequest($request);
30 $result = $form->getData();
31 } else {
32 $result = "No result yet.";
33 }
34
35 //Step 5: Render the radio with the enclosing form.
36 return
37 "<pre>" . print_r($result, true) . "</pre><br/>" .
38 $renderer->render($form);
39}
global $DIC
Definition: feed.php:28
base()
Base example showing how to plug a radio into a form.
Definition: base.php:10