ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
show_form_in_modal.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
18 {
19  global $DIC;
20 
21  $renderer = $DIC->ui()->renderer();
22  $request = $DIC->http()->request();
23  $factory = $DIC->ui()->factory();
24 
25  // declare roundtrip with inputs and form action.
26  $modal = $factory->modal()->roundtrip(
27  'roundtrip with form',
28  null,
29  [
30  $factory->input()->field()->text('some text'),
31  $factory->input()->field()->numeric('some numbere'),
32  ],
33  '#'
34  );
35 
36  // declare something that triggers the modal.
37  $open = $factory->button()->standard('open modal', '#')->withOnClick($modal->getShowSignal());
38 
39  // please use ilCtrl to generate an appropriate link target
40  // and check it's command instead of this.
41  if ('POST' === $request->getMethod()) {
42  $modal = $modal->withRequest($request);
43  $data = $modal->getData();
44  } else {
45  $data = 'no results yet.';
46  }
47 
48  return
49  '<pre>' . print_r($data, true) . '</pre>' .
50  $renderer->render([$open, $modal]);
51 }
$renderer
show_form_in_modal()
description: > Example for rendering a round trip modal.
global $DIC
Definition: shib_login.php:25