2012-12-13 16:33:58 +01:00
|
|
|
# How to Show Help Text on CMS Form Fields
|
|
|
|
|
|
|
|
Sometimes you need to express more context for a form field
|
|
|
|
than is suitable for its `<label>` element.
|
|
|
|
The CMS provides you with an easy way to transform
|
|
|
|
form field attributes into either help text
|
|
|
|
shown alongside the field, or a tooltip which shows on demand.
|
|
|
|
|
|
|
|
The `FormField->setDescription()` method will add a `<span class="description">`
|
|
|
|
at the last position within the field, and expects unescaped HTML content.
|
|
|
|
|
|
|
|
:::php
|
|
|
|
TextField::create('MyText', 'My Text Label')
|
|
|
|
->setDescription('More <strong>detailed</strong> help');
|
|
|
|
|
|
|
|
To show the help text as a tooltip instead of inline,
|
2014-11-07 20:43:57 +01:00
|
|
|
add a `.cms-description-tooltip` class.
|
2012-12-13 16:33:58 +01:00
|
|
|
|
|
|
|
:::php
|
|
|
|
TextField::create('MyText', 'My Text Label')
|
|
|
|
->setDescription('More <strong>detailed</strong> help')
|
2013-09-20 15:12:59 +02:00
|
|
|
->addExtraClass('cms-description-tooltip');
|
2012-12-13 16:33:58 +01:00
|
|
|
|
|
|
|
Tooltips are only supported
|
|
|
|
for native, focusable input elements, which excludes
|
|
|
|
more complex fields like `GridField`, `UploadField`
|
|
|
|
or `DropdownField` with the chosen.js behaviour applied.
|
|
|
|
|
|
|
|
Note: For more advanced help text we recommend using
|
2015-02-28 01:09:15 +01:00
|
|
|
[Custom form field templates](../form_templates);
|