Problem/Motivation
It would be nice to have the field_example module demonstrate how a formatter plugin can expose user definable configuration on the manage display page.
Proposed resolution
Update one of the two existing formatter plugins so that it provides a configuration option. Right now they're both pretty simple formatters and we can make one of the two more complex without detracting from the learning experience.
This updates the \Drupal\field_example\Plugin\Field\FieldFormatter\ColorBackgroudFormatter plugin so that it has a user defined configuration option which can toggle on/off some additional logic that will attempt to automatically set the foreground color of the text depending on the lightness of the background color. This seemed like a real use-case without requiring a lot of extra code unrelated to thing we're trying to demonstrate which is how to make a formatter configurable.
Issue fork examples-3282251
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
eojthebraveComment #5
jungleThe MR is great. Thanks! The field widget allows color values, e.g.
800080, but the formatter here expects value like#800080, leave this to another issue.Comment #7
jungle