0

I created an module polls and entity poll using Drupal Console

I want to add default entity_type on installation. Currently I added only one field to it field_image.

I created following files

FILENAME : field.field.poll.article.field_image.yml

langcode: en
status: true
dependencies:
  config:
    - field.storage.poll.field_image
    - polls.poll_type.article
  module:
    - image
id: poll.article.field_image
field_name: field_image
entity_type: poll
bundle: article
label: Image
description: ''
required: false
translatable: true
default_value: {  }
default_value_callback: ''
settings:
  file_directory: '[date:custom:Y]-[date:custom:m]'
  file_extensions: 'png gif jpg jpeg'
  max_filesize: ''
  max_resolution: ''
  min_resolution: ''
  alt_field: true
  title_field: false
  alt_field_required: true
  title_field_required: false
  default_image:
    uuid: null
    alt: ''
    title: ''
    width: null
    height: null
  handler: 'default:file'
  handler_settings: {  }
field_type: image

FILENAME : field.storage.poll.field_image.yml

langcode: en
status: true
dependencies:
  module:
    - file
    - image
    - polls
id: poll.field_image
field_name: field_image
entity_type: poll
type: image
settings:
  uri_scheme: public
  default_image:
    uuid: null
    alt: ''
    title: ''
    width: null
    height: null
  target_type: file
  display_field: false
  display_default: false
module: image
locked: false
cardinality: 1
translatable: true
indexes:
  target_id:
    - target_id
persist_with_no_fields: false
custom_storage: false

Field is created but it is coming as hidden in Form. How can I show it when modules get installed.

Please suggest.

--

Thanks

1

Configure the field in the form display, export this file

core.entity_form_display.poll.article.default.yml

and put it in the folder /config/install. Remove the uuid line from the yaml file.

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.