ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
base.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
42function base()
43{
44 //Step 1: Declare dependencies
45 global $DIC;
46 $ui = $DIC->ui()->factory();
47 $renderer = $DIC->ui()->renderer();
48 $request = $DIC->http()->request();
49
50 //Step 2: define the radio with options
51 $radio = $ui->input()->field()->radio("Radio", "check an option")
52 ->withOption('value1', 'label1', 'byline1')
53 ->withOption('10', 'numeric value (ten)', 'byline2')
54 ->withOption('030', 'not-numeric value', 'byline3');
55
56 //Step 3: define form and form actions
57 $form = $ui->input()->container()->form()->standard('#', ['radio' => $radio]);
58
59 //Step 4: implement some form data processing.
60 if ($request->getMethod() == "POST") {
61 $form = $form->withRequest($request);
62 $result = $form->getData();
63 } else {
64 $result = "No result yet.";
65 }
66
67 //Step 5: Render the radio with the enclosing form.
68 return
69 "<pre>" . print_r($result, true) . "</pre><br/>" .
70 $renderer->render($form);
71}
$renderer
global $DIC
Definition: shib_login.php:26