ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
base_with_data.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
31 function base_with_data()
32 {
33  // Step 0: Declare dependencies
34  global $DIC;
35  $ui = $DIC->ui()->factory();
36  $renderer = $DIC->ui()->renderer();
37  $request = $DIC->http()->request();
38 
39  // Step 1: Define the tag input field
40  $tag_input = $ui->input()->field()->tag(
41  "Basic TagInput",
42  ['Interesting & fascinating', 'Boring, dull', 'Animating', 'Repetitious'],
43  "Just some tags"
44  );
45 
46  // Step 2, define form and form actions
47  $form = $ui->input()->container()->form()->standard('#', ['f2' => $tag_input]);
48 
49  // Step 3, implement some form data processing.
50  if ($request->getMethod() === "POST") {
51  $form = $form->withRequest($request);
52  $result = $form->getData();
53  } else {
54  $result = "No result yet.";
55  }
56 
57  // Step 4, return the rendered form with data
58  return "<pre>"
59  . print_r($result, true)
60  . "</pre><br/>"
61  . $renderer->render($form);
62 }
$renderer
base_with_data()
description: > The example shows how to create and render a basic tag input field and attach it to a...
global $DIC
Definition: shib_login.php:25