ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
in_form.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
42function in_form()
43{
44 // Step 0: Declare dependencies
45 global $DIC;
46 $ui = $DIC->ui()->factory();
47 $renderer = $DIC->ui()->renderer();
48 $request = $DIC->http()->request();
49
50 // Step 1: Define the input field.
51 // See the implementation of a UploadHandler in components/ILIAS/UI_/classes/class.ilUIDemoFileUploadHandlerGUI.php
52 $file = $ui->input()->field()->file(new \ilUIDemoFileUploadHandlerGUI(), "File Upload", "You can drop your files here");
53
54 // Step 2: Define the form and attach the field.
55 $form = $ui->input()->container()->form()->standard('#', ['file' => $file]);
56
57 // Step 3: Define some data processing.
58 $result = '';
59 if ($request->getMethod() == "POST") {
60 $form = $form->withRequest($request);
61 $result = $form->getData();
62 }
63
64 // Step 4: Render the form/result.
65 return
66 "<pre>" . print_r($result, true) . "</pre><br/>" .
67 $renderer->render($form);
68}
$renderer
Class ilUIDemoFileUploadHandlerGUI.
global $DIC
Definition: shib_login.php:26