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