Drupal 8-如何以编程方式在管理表单下启用自定义字段?

时间:2018-09-19 12:16:08

标签: drupal-8 drupal-fields drupal-field-api

我创建了一个drupal8模块,该模块以编程方式创建了自定义用户字段。它显示在“管理字段”部分,但不能在“管理表单显示”和“管理显示”部分中启用/查看。

我尝试覆盖entiry_form_display但没有成功。

core.entity_form_display.user.facebook.default.yml

langcode: en
status: true
dependencies:
  config:
    - field.field.user.user.field_facebook
  module:
    - field_layout
    - layout_discovery
    - user
id: user.field_facebook.default
targetEntityType: user
bundle: field_facebook
mode: default
content:
  field_facebook:
    type: string
    weight: 200
    label: above
    settings:
      link_to_entity: false
    third_party_settings: {  }
hidden: {  }

field.field.user.user.field_facebook.yml

langcode: en
status: true
dependencies:
  config:
    - field.storage.user.field_facebook
  module:
    - user
id: user.user.field_facebook
field_name: field_facebook
entity_type: user
bundle: user
label: 'Facebook'
description: ''
required: false
translatable: false
default_value: {  }
default_value_callback: ''
settings: {  }
field_type: string

field.storage.user.field_fullcontact_facebook.yml

langcode: en
status: true
dependencies:
  module:
    - user
id: user.field_facebook
field_name: field_facebook
entity_type: user
type: string
settings: { 
  max_length: 255
  is_ascii: false
  case_sensitive: false
 }
module: core
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

1 个答案:

答案 0 :(得分:0)

persist_with_no_fields:是

尝试一下。