ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
base.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
20 function base()
21 {
22  global $DIC;
23  $factory = $DIC->ui()->factory();
24  $renderer = $DIC->ui()->renderer();
25 
26  $message1 = 'Toggle Button has been turned on';
27  $message2 = 'Toggle Button has been turned off';
28  $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
29 
30  $modal = $factory->modal()->interruptive('ON', $message1, $form_action);
31  $modal2 = $factory->modal()->interruptive('OFF', $message2, $form_action);
32 
33  //Note, important do not miss to set a proper aria-label (see rules above).
34  //Note that aria-pressed is taken care off by the default implementation.
35  $button = $factory->button()->toggle("", $modal->getShowSignal(), $modal2->getShowSignal())
36  ->withAriaLabel("Switch the State of XY");
37 
38  return $renderer->render([$button, $modal, $modal2]);
39 }
$renderer
base()
description: > Example for rendering a Toggle Button.
Definition: base.php:20
global $DIC
Definition: shib_login.php:25