ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
with_value.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
35 function with_value()
36 {
37  //Step 0: Declare dependencies
38  global $DIC;
39  $ui = $DIC->ui()->factory();
40  $renderer = $DIC->ui()->renderer();
41  $request = $DIC->http()->request();
42 
43  //Step 1: Define the URL input field and attach some default value
44  $url_input = $ui->input()->field()->url("Basic Input", "Just some basic input with
45  some default url value.")
46  ->withValue("https://www.ilias.de/");
47 
48  //Step 2: Define the form and attach the section
49  $form = $ui->input()->container()->form()->standard("#", [$url_input]);
50 
51  //Step 3: Define some data processing
52  if ($request->getMethod() == "POST") {
53  $form = $form->withRequest($request);
54  $result = $form->getData()[0] ?? "";
55  } else {
56  $result = "No result yet.";
57  }
58 
59  //Step 4: Render the form with the URL input field
60  return
61  "<pre>" . print_r($result, true) . "</pre><br />" .
62  $renderer->render($form);
63 }
$renderer
global $DIC
Definition: shib_login.php:22
with_value()
description: > This example shows how to create and render a basic URL input field with an value att...
Definition: with_value.php:35