ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
in_form.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
26 function in_form()
27 {
28  // Step 0: Declare dependencies
29  global $DIC;
30  $ui = $DIC->ui()->factory();
31  $renderer = $DIC->ui()->renderer();
32  $request = $DIC->http()->request();
33 
34  // Step 1: Define the input field.
35  // See the implementation of a UploadHandler in components/ILIAS/UI_/classes/class.ilUIDemoFileUploadHandlerGUI.php
36  $file = $ui->input()->field()->file(new \ilUIDemoFileUploadHandlerGUI(), "File Upload", "You can drop your files here");
37 
38  // Step 2: Define the form and attach the field.
39  $form = $ui->input()->container()->form()->standard('#', ['file' => $file]);
40 
41  // Step 3: Define some data processing.
42  $result = '';
43  if ($request->getMethod() == "POST") {
44  $form = $form->withRequest($request);
45  $result = $form->getData();
46  }
47 
48  // Step 4: Render the form/result.
49  return
50  "<pre>" . print_r($result, true) . "</pre><br/>" .
51  $renderer->render($form);
52 }
$renderer
in_form()
description: > Example of how to process passwords.
Definition: in_form.php:26
Class ilUIDemoFileUploadHandlerGUI.
global $DIC
Definition: shib_login.php:25