let’s suppose that there is an Alignment field (field_alignment), that had “Left” and “Right” as options. However, the Article content type was added, and it needed a “Center” alignment option, while the other content types needed to only have the original options. Additionally, existing content defaults to “Right” alignment, but the Article content type should use “Center” as the default value.
With that in mind, let’s walk through how to do this in Drupal using the allowed_values_function and default_value_callback field configuration values.
Allowed Values
First we will alter our allowed values to add “Center” as an alignment option for Article content.
In the field instance definition configuration file, set the allowed_values_function key. Note that the allowed_values entries can be removed once an allowed_values_function is in place.
field.storage.node.field_alignment.yml