PHPackages                             nswdpc/silverstripe-field-hint - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. nswdpc/silverstripe-field-hint

ActiveSilverstripe-vendormodule[Templating &amp; Views](/categories/templating)

nswdpc/silverstripe-field-hint
==============================

Allows developers to add usage hints for templates to consider when rendering the field

v1.1.0(9mo ago)04.6k↑100%[1 PRs](https://github.com/nswdpc/silverstripe-field-hint/pulls)1BSD-3-ClausePHP

Since Jul 27Pushed 9mo ago2 watchersCompare

[ Source](https://github.com/nswdpc/silverstripe-field-hint)[ Packagist](https://packagist.org/packages/nswdpc/silverstripe-field-hint)[ RSS](/packages/nswdpc-silverstripe-field-hint/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (14)Used By (1)

Field hinting for Silverstripe forms
====================================

[](#field-hinting-for-silverstripe-forms)

This module allows developers to add usage hints to form fields. Hints are just arbitrary string values.

The hints can be used by themes and templates in a project to render the field in a specific way, to be interpreted by whatever frontend UI-kit is in use for your site.

This avoids polluting module PHP code with theme-specific CSS classes.

Instead of this: `$field->addExtraClass('btn btn-danger')`

...do this `$field->setHint('danger')`.

Default fields
--------------

[](#default-fields)

Out-of-the-box the following fields are configured to support the `Hintable` extension:

- `FormAction` - for action priorities
- `CompositeField` - to assist in rendering child fields in a certain way
- `HTMLReadonlyField` - to display the value and title in a specific way

No changes are made to the field itself, the extension just exposes some methods on the field to use in module code.

Usage
-----

[](#usage)

**Important**: In your theme or project, you need to provide a template that is used by the class using the Hintable extension. [Read: template inheritance](https://docs.silverstripe.org/en/5/developer_guides/templates/template_inheritance/).

### Forms

[](#forms)

Set field hints on your forms:

```
