Example showing how keys can be used when attaching input fields to a form.
6{
7
9 $ui =
$DIC->ui()->factory();
10 $renderer =
$DIC->ui()->renderer();
11 $request =
$DIC->http()->request();
12
13
14 $some_input = $ui->input()->field()
15 ->text("Input", "Any Input");
16
17
18 $DIC->ctrl()->setParameterByClass(
19 'ilsystemstyledocumentationgui',
20 'example_name',
21 'keys'
22 );
23 $form_action =
$DIC->ctrl()->getFormActionByClass(
'ilsystemstyledocumentationgui');
24
25
26
27 $form = $ui->input()->container()->form()->standard(
28 $form_action,
29 [ 'input1' => $some_input->withLabel("Input 1")
30 , 'input2' => $some_input->withLabel("Input 2")
31 ]
32 );
33
34
35 if ($request->getMethod() == "POST"
36 && $request->getQueryParams()['example_name'] == 'keys') {
37 $form = $form->withRequest($request);
39 } else {
41 }
42
43
44 return
45 "<pre>" . print_r(
$result,
true) .
"</pre><br/>" .
46 $renderer->render($form);
47}