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'

Section

Description

Purpose
Sections are used to visually group inputs to a common context.
Composition
Sections are composed of inputs. They carry a label and are visible for the client.

Rivals

Groups
Groups are used as purely logical units, while sections visualize the correlation of fields.

Rules

Composition
  1. Sections SHOULD comprise 2 to 5 Settings.
  2. More than 5 Settings SHOULD be split into two areas unless this would tamper with the “familiar” information architecture of forms.
  3. In standard forms, there MUST NOT be a Setting without an enclosing Titled Form Section. If necessary a Titled Form Section MAY contain only one single Setting.
Wording
  1. The label SHOULD summarize the contained settings accurately from a user’s perspective.
  2. The title SHOULD contain less than 30 characters.
  3. The titles MUST be cross-checked with similar sections in other objects or services to ensure consistency throughout ILIAS.
  4. In doubt consistency SHOULD be prioritized over accuracy in titles.

Example 1: Base

No result yet.

Equals 10

Put in a number.
Put in a number.
<?php
 
declare(strict_types=1);
 
namespace ILIAS\UI\examples\Input\Field\Section;
 
/**
 * Example showing how sections can be used to attach transformation and constraints on
 * multiple fields at once. Note that sections have a standard way of displaying
 * constraint violations to the user.
 */
function base()
{
    //Step 0: Declare dependencies
    global $DIC;
    $ui = $DIC->ui()->factory();
    $lng = $DIC->language();
    $renderer = $DIC->ui()->renderer();
    $request = $DIC->http()->request();
    $data = new \ILIAS\Data\Factory();
    $refinery = new \ILIAS\Refinery\Factory($data, $lng);
 
    //Step 1: Implement transformation and constraints
    $sum = $refinery->custom()->transformation(function ($vs) {
        list($l, $r) = $vs;
        $s = $l + $r;
        return $s;
    });
    $equal_ten = $refinery->custom()->constraint(function ($v) {
        return $v == 10;
    }, "The sum must equal ten");
 
    //Step 2: Define inputs
    $number_input = $ui->input()->field()->numeric("number", "Put in a number.");
 
    //Step 3: Define the group, add the inputs to the group and attach the
    //transformation and constraint
    $group = $ui->input()->field()->section(
        [ $number_input->withLabel("Left"), $number_input->withLabel("Right")],
        "Equals 10",
        "Left and Right must equal 10"
    )
        ->withAdditionalTransformation($sum)
        ->withAdditionalTransformation($equal_ten);
 
    //Step 3, define form and form actions, attach the group to the form
    $form = $ui->input()->container()->form()->standard('#', [$group]);
 
    //Step 4, implement some form data processing.
    if ($request->getMethod() == "POST") {
        $form = $form->withRequest($request);
        $result = $form->getData()[0] ?? "";
    } else {
        $result = "No result yet.";
    }
 
    //Return the rendered form
    return
        "<pre>" . print_r($result, true) . "</pre><br/>" .
        $renderer->render($form);
}
 

Example 2: Disabled

No result yet.

Equals 10

Put in a number.
Put in a number.
<?php
 
declare(strict_types=1);
 
namespace ILIAS\UI\examples\Input\Field\Section;
 
/**
 * Example showing how disabled sections can be used to attach transformation and constraints on
 * multiple fields at once.
 */
function disabled()
{
    //Step 0: Declare dependencies
    global $DIC;
    $ui = $DIC->ui()->factory();
    $lng = $DIC->language();
    $renderer = $DIC->ui()->renderer();
    $request = $DIC->http()->request();
    $data = new \ILIAS\Data\Factory();
    $refinery = new \ILIAS\Refinery\Factory($data, $lng);
 
    //Step 1: Implement transformation and constraints
    $sum = $refinery->custom()->transformation(function ($vs) {
        list($l, $r) = $vs;
        $s = $l + $r;
        return $s;
    });
    $equal_ten = $refinery->custom()->constraint(function ($v) {
        return $v == 10;
    }, "The sum must equal ten");
 
    //Step 2: Define inputs
    $number_input = $ui->input()->field()->numeric("number", "Put in a number.")->withValue(5);
 
    //Step 3: Define the group, add the inputs to the group and attach the
    //transformation and constraint
    $group = $ui->input()->field()->section(
        [ $number_input->withLabel("Left"), $number_input->withLabel("Right")],
        "Equals 10",
        "Left and Right must equal 10"
    )
        ->withAdditionalTransformation($sum)
        ->withAdditionalTransformation($equal_ten)
        ->withDisabled(true);
 
    //Step 3, define form and form actions, attach the group to the form
    $form = $ui->input()->container()->form()->standard('#', [$group]);
 
    //Step 4, implement some form data processing.
    if ($request->getMethod() == "POST") {
        $form = $form->withRequest($request);
        $result = $form->getData()[0];
    } 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