3

I'd like to do this in Drupal 8:

enter image description here


I need to change the label of the Title field on a custom content type without using admin panels.

I know this is possible via the admin menu, but I feel like I should be able to have the module fully set up when it is installed. Is there a flag in the content type's configuration file that I can add to override the default value?

Here's my node.type.employee.yml file

langcode: en
status: true
dependencies: {  }
name: 'Employee'
type: employee
description: ''
help: ''
new_revision: false
preview_mode: 1
display_submitted: true
third_party_settings: {  }

2 Answers 2

5

This is stored as a field override configuration. It's a separate config entity with the name core.base_field_override.node.your_node_type.title.

2
  • Thanks for your reply! Would I just need to add that as a yml file in my /config/install directory? Or is there any documentation on how you modify that configuration? Jun 2, 2016 at 18:33
  • Yes, you just add that field. change it in the UI, export and put that in your config folder. Pretty save if it is your own node type, as it can't already exist. Providing a default to change someone else's node type could be a problem if a user already customized it, it would fail.
    – Berdir
    Jun 2, 2016 at 18:41
2

Go to /admin/structure/types/manage/examplecontenttype

change the the title label to what you want.

export the config, on the command line using drush, you'd use

drush cex -y

then commit the resulting .yml file

/sites/default/sync/node.type.examplecontenttype.yml

Such as:

uuid: 5b0d84b8-b264-48c4-b726-1150966d955e
langcode: en
status: true
dependencies:
  config:
    - node.type.examplecontenttype
id: node.examplecontenttype.title
field_name: title
entity_type: node
bundle: examplecontenttype
label: 'Your Custom Label Goes Here.'
description: ''
required: true
translatable: true
default_value: {  }
default_value_callback: ''
settings: {  }
field_type: string

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.