Skip to content

EasyAdmin Color Field

Edit this page

This field is used to represent a text content that stores a single color value following the HTML 5 color format (a 7-character string specifying an RGB color in lower case hexadecimal notation: #000000).

In form pages (edit and new) it looks like this:

Default style of EasyAdmin color field

Basic Information

  • PHP Class: EasyCorp\Bundle\EasyAdminBundle\Field\ColorField
  • Doctrine DBAL Type used to store this value: string
  • Symfony Form Type used to render the field: ColorType
  • Rendered as:

    1
    <input type="color" value="...">

Options

showSample

By default, in read-only pages (index and detail) the field is represented as a sample of its color (using a <span> HTML element with a background color of the same value). If you prefer to not display that sample, use this option:

1
yield ColorField::new('...')->showSample(false);

showValue

By default, in read-only pages (index and detail) the hexadecimal value of the color is not displayed (only a sample of the color is displayed). Use this option to display that hexadecimal value:

1
yield ColorField::new('...')->showValue();
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version