Modifier: :sanitize_html_class
Sanitize as a CSS class. Write it after a colon: {Field:1:sanitize_html_class}
About
| Product | GravityView |
|---|---|
| Requires | GravityView 2.0 or later |
| Works on | form fields |
| In the picker | Change the output |
How to use it
Turn a value into CSS classes
Punctuation is removed and spaces are kept, so each word becomes its own class. Useful for styling an entry by what someone typed or chose.
Write
<div class="{Tags:4:sanitize_html_class}">…</div>Get
<div class="red green blue">…</div>Examples
Rendered by real Gravity Forms and GravityKit PHP against a test entry.
| Merge tag | Output | Without the modifier |
|---|---|---|
{Notes:2:sanitize_html_class} | its -- bQUICKb brown Fox jumps over the lazy dog and it wasnt bthatb slow steadyAda Lovelace wrote the first algorithm | it's -- <b>QUICK</b>, brown Fox jumps over the lazy dog and it wasn't <b>that</b> slow & steady.<br /> <br /> Ada Lovelace wrote the first algorithm. |
Where the merge tag picker offers it
Form fields: Single line text · Paragraph text · Email · Website · Hidden · Consent · Signature · Drop down · Radio buttons · Checkboxes, one choice · Multi select · Image choice · Multiple choice · Post category · Number · Calculation · Product · Product (single) · Product (hidden) · Product price · Quantity · Option · Shipping · Shipping (single) · Total · Date, after a custom format · Time · Name, one part · Address, one part · Phone, standard format · File upload · Post image · List · Repeater.
Where it is left out
| Field kinds | Why |
|---|---|
| Checkboxes · Name · Address | Skipped on the whole field. The field is stored as several values, and GravityView skips it. Write one input instead, like .3 for a first name. |
| Date | Needs a date format first. GravityView changes the stored date (2024-03-09), which has no letters. Add “Custom date format” or “Human-readable time difference” first. |
| Phone, international format | Works on the stored record. An international phone field stores a record like {"country":"US",…}. GravityView would change that record, not the number people see. |