ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
with_value.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
35function 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:26