ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
base_with_data.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
48{
49 // Step 0: Declare dependencies
50 global $DIC;
51 $ui = $DIC->ui()->factory();
52 $renderer = $DIC->ui()->renderer();
53 $request = $DIC->http()->request();
54
55 // Step 1: Define the tag input field
56 $tag_input = $ui->input()->field()->tag(
57 "Basic TagInput",
58 ['Interesting & fascinating', 'Boring, dull', 'Animating', 'Repetitious'],
59 "Just some tags"
60 );
61
62 // Step 2, define form and form actions
63 $form = $ui->input()->container()->form()->standard('#', ['f2' => $tag_input]);
64
65 // Step 3, implement some form data processing.
66 if ($request->getMethod() === "POST") {
67 $form = $form->withRequest($request);
68 $result = $form->getData();
69 } else {
70 $result = "No result yet.";
71 }
72
73 // Step 4, return the rendered form with data
74 return "<pre>"
75 . print_r($result, true)
76 . "</pre><br/>"
77 . $renderer->render($form);
78}
$renderer
global $DIC
Definition: shib_login.php:26