ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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  //Step 3: implement some form data processing.
37  if ($request->getMethod() == "POST") {
38  $form = $form->withRequest($request);
39  $groups = $form->getInputs();
40  foreach ($groups as $group) {
41  if ($group->getError()) {
42  $result = $group->getError();
43  } else {
44  //The result is sumarized through the transformation
45  $result = $form->getData();
46  }
47  };
48  } else {
49  $result = "No result yet.";
50  }
51 
52  //Step 4: Render the form.
53  return
54  "<pre>" . print_r($result, true) . "</pre><br/>" .
55  $renderer->render($form);
56 }
$result
base()
Definition: base.php:4
$DIC
Definition: xapitoken.php:46