3

anyone know of a quick example of how to change the field settings for a text area (plain) to formatted and set the input formatter (or maybe it will use default)? Will this require a resave of all the data or can it just be changed for the entity type? I currently have a lot of existing data on this site.

The field is currently stored as the type string, Text (plain). I need to change it to text_long, Text (formatted, long).

Thanks

3

Attention for Drupal 8:

You need to update at least 3 or 4 yml files

field.field.node.page.field_description.yml

(same change)

field.storage.node.field_description.yml

--- a/config/default/field.storage.node.field_description.yml
+++ b/config/default/field.storage.node.field_description.yml
@@ -4,13 +4,13 @@
 dependencies:
   module:
     - node
+    - text
 id: node.field_description
 field_name: field_description
 entity_type: node
-type: string_long
-settings:
-  case_sensitive: false
-module: core
+type: text_long
+settings: {  }
+module: text
 locked: false
 cardinality: 1
 translatable: true

core.entity_form_display.node.page.default.yml

-type: string_textarea 
+type: text_textarea

core.entity_view_display.node.page.default.yml

-type: basic_string
+type: text_default

Maybe the last 2 ones you can deal with those changes on UI(go to each teaser and save). But I did in config folder.

  • While this will have changed the appearance of the node form, the data will not be saved correctly, and will not be displayed correctly. – Dalin Oct 24 at 14:54
1

Oh wow, I just tried something in hopes of it being easy and it was a breeze!...

I already have all my config exported to code so I compared a text_long field to my current string_long field and just merged the differences, it worked beautifully. Something like the changes in the following example patch:

--- config/prod/field.field.node.page.field_description.yml (revision 3ef14eada9090087d33a10ec532732e515fef151)
+++ config/prod/field.field.node.page.field_description.yml (revision )
@@ -5,6 +5,8 @@
   config:
     - field.storage.node.field_description
     - node.type.page
+  module:
+    - text
 id: node.researcher.field_description
 field_name: field_description
 entity_type: node
@@ -16,4 +18,4 @@
 default_value: {  }
 default_value_callback: ''
 settings: {  }
-field_type: string_long
+field_type: text_long

imported the changed config and walah! Just beautiful.

  • 2
    I doubt it really just works like that. Note that the field type is also in the storage, and that changing the field type results in a different field schema, which drupal will actually prevent you from changing if you try it on the field storage config. – Berdir Oct 23 '16 at 11:12
  • @Berdir of course you are correct. Guess I am still looking to solve this. Seemed good at first but then I noted the display was rendering with html markup. – nicholas.alipaz Oct 24 '16 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.