Base example showing how to plug date-inputs into a form.
6{
7
8
10
11 $ui =
$DIC->ui()->factory();
12 $renderer =
$DIC->ui()->renderer();
13 $request =
$DIC->http()->request();
15
16
17
18 $duration = $ui->input()->field()->duration("Pick a time-span", "This is the byline text");
19 $time = $duration->withTimeOnly(true)->withRequired(true);
20 $timezone = $duration
21 ->withTimezone('America/El_Salvador')
22 ->withUseTime(true)
23 ->withByline('timezone and both time and date');
24
25
26 $form = $ui->input()->container()->form()->standard(
27 '#',
28 [
29 'duration' => $duration,
30 'time' => $time,
31 'timezone' => $timezone,
32 'disabled' => $duration->withLabel('disabled')->withDisabled(true)
33 ]
34 );
35
37
38
39 if ($request->getMethod() == "POST") {
40 $form = $form->withRequest($request);
41 $groups = $form->getInputs();
42 foreach ($groups as $group) {
43 if ($group->getError()) {
45 } else {
46
48 }
49 }
50 } else {
52 }
53
54
55 return
56 "<pre>" . print_r(
$result,
true) .
"</pre><br/>" .
57 $renderer->render($form);
58}