Documentation
Kitchen Sink documentation of style: 'Delos' of skin: 'ILIAS'
Url
Description
- Purpose
- The URL Input is intended for entering a single URL.
- Composition
- URL Inputs will render an input-tag with type="url".
- Effect
- URL Inputs are restricted to a single URL without a label. A URI check will ensure a correct URL format (e.g. 'https://www.ilias.de/') is inserted.
- Context
- The single URL Input is used in UI-forms.
Rivals
- Text Input
- use a Text Input if users should input texts.
- Link Input
- use a Link Input if users may also set a label for the URL
Rules
- Usage
- The URL Input MUST NOT be used if a URL label has to be set.
Example 1: Base
<?php declare(strict_types=1); namespace ILIAS\UI\examples\Input\Field\Url; /** * This example shows how to create and render a basic input field and attach it to a form. * It does not contain any data processing. */ function base() { //Step 0: Declare dependencies global $DIC; $ui = $DIC->ui()->factory(); $renderer = $DIC->ui()->renderer(); //Step 1: Define the URL input field $url_input = $ui->input()->field()->url("Basic Input", "Just some basic input"); //Step 2: Define the form and attach the section $form = $ui->input()->container()->form()->standard("#", [$url_input]); //Step 4: Render the form with the URL input field return $renderer->render($form); }
Example 2: Disabled
<?php declare(strict_types=1); namespace ILIAS\UI\examples\Input\Field\Url; /** * This example shows how to create and render a disabled URL input field and attach it to a form. * It does not contain any data processing. */ function disabled() { //Step 0: Declare dependencies global $DIC; $ui = $DIC->ui()->factory(); $renderer = $DIC->ui()->renderer(); //Step 1: Define the URL input field $url_input = $ui->input()->field()->url("Disabled Input", "Just some disabled input")->withDisabled(true); //Step 2: Define the form and attach the section $form = $ui->input()->container()->form()->standard("#", [$url_input]); //Step 4: Render the form with the URL input field return $renderer->render($form); }
Example 3: With error
<?php declare(strict_types=1); namespace ILIAS\UI\examples\Input\Field\Url; /** * This example shows how to create and render a basic URL input field with an error and * attach to it. It does not contain any data processing. */ function with_error() { //Step 0: Declare dependencies global $DIC; $ui = $DIC->ui()->factory(); $renderer = $DIC->ui()->renderer(); //Step 1: Define the URL input field $url_input = $ui->input()->field()->url("Basic Input", "Just some basic input with some error attached.") ->withError("Some error"); //Step 2: Define the form and attach the section $form = $ui->input()->container()->form()->standard("#", [$url_input]); //Step 4: Render the form with the URL input field return $renderer->render($form); }
Example 4: With value
No result yet.
<?php declare(strict_types=1); namespace ILIAS\UI\examples\Input\Field\Url; /** * This example shows how to create and render a basic URL input field with an value * attached to it. It does also contain data processing. */ function with_value() { //Step 0: Declare dependencies global $DIC; $ui = $DIC->ui()->factory(); $renderer = $DIC->ui()->renderer(); $request = $DIC->http()->request(); //Step 1: Define the URL input field and attach some default value $url_input = $ui->input()->field()->url("Basic Input", "Just some basic input with some default url value.") ->withValue("https://www.ilias.de/"); //Step 2: Define the form and attach the section $form = $ui->input()->container()->form()->standard("#", [$url_input]); //Step 3: Define some data processing if ($request->getMethod() == "POST") { $form = $form->withRequest($request); $result = $form->getData()[0] ?? ""; } else { $result = "No result yet."; } //Step 4: Render the form with the URL input field return "<pre>" . print_r($result, true) . "</pre><br />" . $renderer->render($form); }
Relations
- Parents
- UIComponent
- Input
- Field