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
46function base()
47{
48 //Step 0: Declare dependencies
49 global $DIC;
50
51 $ui = $DIC->ui()->factory();
52 $renderer = $DIC->ui()->renderer();
53 $request = $DIC->http()->request();
54 $ctrl = $DIC->ctrl();
55
56
57 //Step 1: define the input
58 $duration = $ui->input()->field()->duration("Pick a time-span", "This is the byline text");
59 $timezone = $duration
60 ->withTimezone('America/El_Salvador')
61 ->withUseTime(true)
62 ->withByline('timezone and both time and date');
63
64 $time = $duration->withTimeOnly(true)->withRequired(true)->withLabels('start time', 'end time');
65
66 //Step 2: define form and form actions, attach the input
67 $form = $ui->input()->container()->form()->standard(
68 '#',
69 [
70 'duration' => $duration,
71 'time' => $time,
72 'timezone' => $timezone,
73 'disabled' => $duration->withLabel('disabled')->withDisabled(true)
74 ]
75 );
76
77 $result = "";
78
79 //Step 3: implement some form data processing.
80 if ($request->getMethod() == "POST") {
81 $form = $form->withRequest($request);
82 $groups = $form->getInputs();
83 foreach ($groups as $group) {
84 if ($group->getError()) {
85 $result = $group->getError();
86 } else {
87 //The result is sumarized through the transformation
88 $result = $form->getData();
89 }
90 }
91 } else {
92 $result = "No result yet.";
93 }
94
95 //Step 4: Render the form.
96 return
97 "<pre>" . print_r($result, true) . "</pre><br/>" .
98 $renderer->render($form);
99}
$duration
$renderer
global $DIC
Definition: shib_login.php:26