19 declare(strict_types=1);
40 $ui = $DIC->ui()->factory();
42 $request = $DIC->http()->request();
45 $sum =
$refinery->custom()->transformation(
function ($vs) {
48 return "$l + $r = $s";
51 $from_name =
$refinery->custom()->transformation(
function ($v) {
55 case "three":
return 3;
56 case "four":
return 4;
57 case "five":
return 5;
59 case "seven":
return 7;
60 case "eight":
return 8;
61 case "nine":
return 9;
62 case "ten":
return 10;
64 throw new \LogicException(
"PANIC!");
68 $valid_number =
$refinery->custom()->constraint(
function ($v) {
69 return in_array($v, [
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten"]);
70 },
"This is not a number I know...");
74 $number_input = $ui->input()->field()
75 ->text(
"number",
"Put in the name of a number from one to ten.")
76 ->withAdditionalTransformation($valid_number)
77 ->withAdditionalTransformation($from_name);
80 $DIC->ctrl()->setParameterByClass(
81 'ilsystemstyledocumentationgui',
85 $form_action = $DIC->ctrl()->getFormActionByClass(
'ilsystemstyledocumentationgui');
89 $form = $ui->input()->container()->form()->standard(
91 [ $number_input->withLabel(
"Left")
92 , $number_input->withLabel(
"Right")
97 if ($request->getMethod() ==
"POST" 98 && array_key_exists(
'example_name', $request->getQueryParams())
99 && $request->getQueryParams()[
'example_name'] ==
'data_processing') {
100 $form = $form->withRequest($request);
101 $result = $form->getData();
103 $result =
"No result yet.";
108 "<pre>" . print_r($result,
true) .
"</pre><br/>" .