0

For my assignment I have to write a module that when enabled will prepend a text of string "Hello World" to the body of a text field of hello_world_article content type.

I first tried to use Drupal 8 config export to try to set a default value (hello World) by using a yml file. However I get an error enabling the module that " field.field.node.hello_world_article.body already exists in active configuration."

My yml file is:

uuid: 42c51471-d897-4cb1-ac37-b2b6cddc6f0e58
langcode: en
status: true
dependencies:
  config:
    - field.storage.node.body
    - node.type.hello_world_article
  module:
    - text
_core:
  default_config_hash: e_0gHBXrh9sHHe-XksjIYpOmFEiugHbtoJdYPxbftAI
id: node.hello_world_article.body
field_name: body
entity_type: node
bundle: hello_world_article
label: Body
description: ''
required: false
translatable: true
default_value:
  -
    summary: ''
    value: "<p><em>Hello World!</em></p>\r\n\r\n<p>&nbsp;</p>\r\n"
    format: basic_html
default_value_callback: ''
settings:
  display_summary: true
field_type: text_with_summary

How else would I get about approaching this problem. Help would be much appreciated.

3
  • You will have to uninstall module first and the install it again!
    – ssibal
    Commented Aug 16, 2016 at 11:59
  • I tried that. The field is defined in another yaml file. However I have to use my module for that.
    – kratos
    Commented Aug 16, 2016 at 16:12
  • Posting because I'm curious.. Why would using JavaScript in this case not be a good idea? Commented Aug 17, 2016 at 5:50

1 Answer 1

0

Create a template override for the field. Because it sounds like a class assignment, I'll leave the actual coding to you.

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.