UPDATE-RATE

Die Test-Installation wird aktuell zwischen 8:00 und 18:00 Uhr stündlich zur vollen Stunde aktualisiert.

Alles neu macht der Mai

ILIAS 9 ist da! Alle Infos zu den Highlights der neuen Version gibt es hier!

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
  1. Number Inputs MUST NOT be used for binary choices.
  2. Magic numbers such as -1 or 0 to specify “limitless” or smoother options MUST NOT be used.
  3. A valid input range SHOULD be specified.

Example 1: Numeric inputs

No result yet.

* Required
Put in a number.
Put in a number.
<?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
  1. UIComponent
  2. Input
  3. Field