Skip to main content
nik's personal space

Main navigation

  • About
  • Profile
  • Blogs
  • Achievements
  • Reach nik
User account menu
  • Log in

Breadcrumb

  1. Home

Drupal 8: Updating field configuration in update hooks

Continuing to Reverting features in update hooks, I encountered a new scenario yesterday where I had to make a field translatable. Somehow we missed to make the field translatable during development and now since we are in update mode we need to handle it for existing sites as well.

At first I looked at the documentation at Drupal.org, which was a bit confusing and not helpful for the case at hand.

Then I looked into some of the core modules but that didn't work for me. For instance comment_update_8300() in docroot/core/modules/comment/comment.install



It made the field translatable in field definition for me using this approach but it didn't update anything in the interface even after doing drush cr and drush entity-updates.

Then I tried to look into how it's done in frontend and found out that it is also stored as entity now and so quickly tried to load it as entity and do the changes. It worked perfectly fine, tricky again and something that might take hours to figure out (it took around three hours for me).

 

Sharing with a hope to make it quicker for others. Please share in comments if you feel the approach is not good / standard OR better approach is available for the same.
Behat tests with Lando and Apple M1
Knowledge required as PHP developer
Drupal - Tips to keep browser CPU usage in check
Thinking about customer success as a developer
Developing or testing Apple Pay
Being pro-active as developer
Effective communication, how I do it
Migrating multi-value non-associative data
Drupal 8: Reverting features in update hooks
Life saver - live dev on Magento Cloud
Certified SAFe® 6 Agilist Badge
BMI IQ - 135
Acquia Certified Cloud Pro 2020
Acquia Certified Front End Specialist - Drupal 9
Triple Certified Drupal Expert - Drupal 9
Acquia Certified Developer - Drupal 9
Acquia Certified Site Studio 6 Site Builder
Acquia Certified Back End Specialist - Drupal 9
Acquia Certified Site Factory Pro
Acquia Certified Developer - Drupal 8
Acquia Certified Developer - Drupal 7
Certified ScrumMaster®
Powered by Drupal