Actions

Developer Area/Core Subsystems/Form API (Pieforms)/Form APIElements/Help Icon

From Mahara Wiki

< Developer Area‎ | Core Subsystems‎ | Form API (Pieforms)‎ | Form APIElements
Revision as of 11:08, 22 December 2022 by Gold (talk | contribs) (Notes on the Help Icon in Pieforms)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Help Icons can be added to Pieform elements by the addition of 'help' => true to the form element array. This will generate a help icon that will load a file via an AJAX callback.

The file name is constructed in get_helpfile_location() and requires that the form also has pluginname and plugintype also set.

Optional: 'helpinlabel' => true can be set to move the help icon into the label so it is close to the text of the label rather than the default location on the far right of the rendered element. This may be of use when a form has non-default layout.

Minimal example:

$searchform = [
    'name' => 'exampleform',
    'plugintype' => 'core',
    'pluginname' => 'view',
    'elements' => [
        'examplecheckbox' => [
            'type' => 'checkbox',
            'class' => 'stacked',
            'title' => get_string('examplecheckboxtitle', 'view'),
            'defaultvalue' => $examplecheckbox,
            'help' => true,
            'helpinlabel' => true,
        ],
    ],
];