ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
base.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
36 function base()
37 {
38  global $DIC;
39  $factory = $DIC->ui()->factory();
40  $renderer = $DIC->ui()->renderer();
41 
42  $message1 = 'Toggle Button has been turned on';
43  $message2 = 'Toggle Button has been turned off';
44  $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
45 
46  $modal = $factory->modal()->interruptive('ON', $message1, $form_action);
47  $modal2 = $factory->modal()->interruptive('OFF', $message2, $form_action);
48 
49  //Note, important do not miss to set a proper aria-label (see rules above).
50  //Note that aria-pressed is taken care off by the default implementation.
51  $button = $factory->button()->toggle("", $modal->getShowSignal(), $modal2->getShowSignal())
52  ->withAriaLabel("Switch the State of XY");
53 
54  return $renderer->render([$button, $modal, $modal2]);
55 }
$renderer
base()
description: > Example for rendering a Toggle Button.
Definition: base.php:36
global $DIC
Definition: shib_login.php:22