有人知道如何将文本区域(纯文本)的字段设置更改为格式化并设置输入格式化程序(或者它将使用默认设置)。这是否需要对所有数据进行重存,还是只对实体类型进行更改?我目前在这个网站上有很多现有的数据。
该字段当前存储为string类型的文本(纯文本)。我需要将它更改为text_long,文本(格式化,长)。
谢谢
发布于 2017-08-29 20:51:16
注意Drupal 8:
您需要至少更新3或4 yml文件。
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: truecore.entity_form_display.node.page.default.yml
-type: string_textarea
+type: text_textareacore.entity_view_display.node.page.default.yml
-type: basic_string
+type: text_default也许最后两个你可以在UI上处理这些变化(转到每个挑逗和保存)。但我在配置文件夹里做了。
发布于 2016-10-21 00:22:38
哦,哇,我只是尝试了一些东西,希望它是容易的,这是一件轻而易举的事情!
我已经将我的所有配置导出为代码,所以我将text_long字段与当前的string_long字段进行比较,并将这些差异合并,效果非常好。类似于以下示例修补程序中的更改:
--- 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导入修改后的配置和瞧!只是很漂亮。
发布于 2020-10-18 23:41:50
您可以通过CHX使用模块Druidfire。
https://gitlab.com/chx_/druidfire
Drush 10命令:drush druidfire:string2formatted entity_type field_name
它不是托管在drupal.org上的,也不太可能是。请谨慎使用。
module_name.install文件的示例update钩子:
/**
* Change field my_field to formatted text.
*/
function module_namee_update_8001() {
\Drupal::service('druidfire')->kaboom('string2formatted', 'node', 'field_my_field');
}https://drupal.stackexchange.com/questions/218392
复制相似问题