Create a hook update to set the link title as optional

Created on 30 March 2023, over 1 year ago
Updated 31 March 2023, over 1 year ago

Problem/Motivation

Recently at Fix the link label as optional instead of required Fixed we updated the link field field to have the label as optional because in some cases the content editors wants to use the save value from "URL" to be the Label. And if is required was necessary to duplicate the URL as Label. Using the field Label as optional the site builders can only fill the URL and if wants to pass a label they can, but if they want to use the label with the same value as URL they can only leave the Label in blank.

Now this is working fine for new installs, since the config was export into config/install, so in order to have this working on existent sites, we need to create a hook update with that change, because Drupal only read the config/install directory during the installation process

Steps to reproduce

Proposed resolution

  1. Implement a hook_update_N
  2. Inform the entity (block_type)
  3. Inform the field_machine_name
  4. Load the config object (field)
  5. Set the settings that represents the label as optional
  6. Save the object

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

1.4

Component

Code

Created by

🇧🇷Brazil renatog Campinas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024