ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
base.php
Go to the documentation of this file.
1 <?php
5 function base()
6 {
7 
8  //Step 0: Declare dependencies
9  global $DIC;
10 
11  $ui = $DIC->ui()->factory();
12  $renderer = $DIC->ui()->renderer();
13  $request = $DIC->http()->request();
14  $ctrl = $DIC->ctrl();
15 
16 
17  //Step 1: define the input
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  //Step 2: define form and form actions, attach the input
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 
36  $result = "";
37 
38  //Step 3: implement some form data processing.
39  if ($request->getMethod() == "POST") {
40  $form = $form->withRequest($request);
41  $groups = $form->getInputs();
42  foreach ($groups as $group) {
43  if ($group->getError()) {
44  $result = $group->getError();
45  } else {
46  //The result is sumarized through the transformation
47  $result = $form->getData();
48  }
49  }
50  } else {
51  $result = "No result yet.";
52  }
53 
54  //Step 4: Render the form.
55  return
56  "<pre>" . print_r($result, true) . "</pre><br/>" .
57  $renderer->render($form);
58 }
$result
base()
Definition: base.php:4
global $DIC
Definition: goto.php:24