Documentation
Kitchen Sink documentation of style: 'Delos' of skin: 'ILIAS'
Numeric
Description
- Purpose
- A numeric field is used to retrieve integer values from the user.
- Composition
- Numeric inputs will render an input-tag with type="number".
- Effect
- The field does not accept any data other than numeric values. When focused most browser will show a small vertical rocker to increase and decrease the value in the field.
Rules
- Usage
- Number Inputs MUST NOT be used for binary choices.
- Magic numbers such as -1 or 0 to specify “limitless” or smoother options MUST NOT be used.
- A valid input range SHOULD be specified.
Example 1: Numeric inputs
No result yet.
<?php declare(strict_types=1); namespace ILIAS\UI\examples\Input\Field\Numeric; /** * Base example showing how to plug a numeric input into a form */ function numeric_inputs() { //Step 0: Declare dependencies global $DIC; $ui = $DIC->ui()->factory(); $renderer = $DIC->ui()->renderer(); $request = $DIC->http()->request(); //Step 1: Declare the numeric input $number_input = $ui->input()->field() ->numeric("Some Number", "Put in a number.") ->withValue(133); $number_input2 = $number_input->withRequired(true)->withValue(''); //Step 2, define form and form actions $form = $ui->input()->container()->form()->standard('#', [ 'n1' => $number_input, 'n2' => $number_input2 ]); //Step 3, implement some form data processing. if ($request->getMethod() == "POST") { $form = $form->withRequest($request); $result = $form->getData(); } else { $result = "No result yet."; } //Return the rendered form return "<pre>" . print_r($result, true) . "</pre><br/>" . $renderer->render($form); }
Relations
- Parents
- UIComponent
- Input
- Field