1

How to alter existing field type instead of creating new one to add new options with custom processing for insert and display of the field.

Use case : upgrade hijri taarikh project that extends the default date field types allows to use Hijri calendar for both select list and popup letting the user add Hijri dates and display Hijri dates.

1 Answer 1

2

To alter how to insert content into the field, define your own field widget and then apply the new widget for the existing field in "manage form display" of the content type.

Field Widget

To alter how the field is displayed, define you own field formatter and apply it in "manage display" in the same way:

Field Formatter

When you start with a field widget or field formatter, the fastest way is to copy an existing one out of core and modify it or use drupal console to generate the scaffolding.

If you only want to modifiy an existing widget/formatter, then extend it, not write a complete new one. This is a good explanation, how to do this:

http://www.sitepoint.com/creating-custom-field-formatters-drupal-8/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.