Skip to content

Instantly share code, notes, and snippets.

@lcube45
Created June 1, 2020 14:57
Show Gist options
  • Save lcube45/a566915181c2b312c05734d15d4329f7 to your computer and use it in GitHub Desktop.
Save lcube45/a566915181c2b312c05734d15d4329f7 to your computer and use it in GitHub Desktop.
Drupal 8 - BaseFieldDefinition - entity_reference_revisions
<?php
// si limitation sur les bundles de paragraphes: renseigner target_bundles
// ajout du widget de paragraphs "classic paragraphs
$fields['paragraphs'] = BaseFieldDefinition::create('entity_reference_revisions')
->setLabel('Paragraphs')
->setDescription('Paragraphs')
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setRequired(TRUE)
->setSetting('handler_settings', ['target_bundles' => []])
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', TRUE)
->setSetting('target_type', 'paragraph')
->setDisplayOptions('form', [
'type' => 'entity_reference_paragraphs'
]);
@lcube45
Copy link
Author

lcube45 commented Jun 1, 2020

Un exemple de BasefieldDefinition pour le type de champ "entity_reference_revisions" permettant de gérer des paragraphes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment