Skip to Main Content
Drupal 8 Module Development - Second Edition
book

Drupal 8 Module Development - Second Edition

by Daniel Sipos
March 2019
Intermediate to advanced content levelIntermediate to advanced
580 pages
15h 3m
English
Packt Publishing
Content preview from Drupal 8 Module Development - Second Edition

Field formatter

Alright, so our field now also has a widget that users can input data with. Let's create the default field formatter to make the field whole.

Before actually coding it, let's establish what we want our formatter to look and behave like. By default, we want the license plate data to be rendered like this:

<span class="license-plate—code">{{ code }}</span> <span class="license-plate—number">{{ number }}</span>  

So, each component is wrapped inside its own span tag, and some handy classes are applied to them. Alternatively, we may want to concatenate the two values together into one single span tag:

<span class="license-plate">{{ code }} {{ number }}</span>  

This could be a setting on the formatter, allowing the user to choose ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Drupal 8 Module Development

Drupal 8 Module Development

Daniel Sipos
Learning Drupal 8

Learning Drupal 8

Rain Michaels
Mastering Drupal 8

Mastering Drupal 8

Chaz Chumley, William Hurley

Publisher Resources

ISBN: 9781789612363Supplemental Content