ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
with_value.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
19 function with_value()
20 {
21  //Step 0: Declare dependencies
22  global $DIC;
23  $ui = $DIC->ui()->factory();
24  $renderer = $DIC->ui()->renderer();
25  $request = $DIC->http()->request();
26 
27  //Step 1: Define the URL input field and attach some default value
28  $url_input = $ui->input()->field()->url("Basic Input", "Just some basic input with
29  some default url value.")
30  ->withValue("https://www.ilias.de/");
31 
32  //Step 2: Define the form and attach the section
33  $form = $ui->input()->container()->form()->standard("#", [$url_input]);
34 
35  //Step 3: Define some data processing
36  if ($request->getMethod() == "POST") {
37  $form = $form->withRequest($request);
38  $result = $form->getData()[0] ?? "";
39  } else {
40  $result = "No result yet.";
41  }
42 
43  //Step 4: Render the form with the URL input field
44  return
45  "<pre>" . print_r($result, true) . "</pre><br />" .
46  $renderer->render($form);
47 }
$renderer
global $DIC
Definition: shib_login.php:25
with_value()
description: > This example shows how to create and render a basic URL input field with an value att...
Definition: with_value.php:19