5

I tried to add a comment field in the Basefieldsdefinitions of my custom entity but in my view the add comment form doesn't appear:

Here's the basefielddefinition

 $fields['comments'] = BaseFieldDefinition::create('comment')
  ->setLabel(t('Kommentare'))
  ->setDescription(t('Kommentare.'))

  ->setSettings(
    array(
      'default_mode'=> 1,
      'per_page'=>50,
      'anonymous'=> 0,
      'form_location'=>1,
      'preview'=> 1,
      'comment_type'=>'image_comment',
      'locked'=>false,

      ))
->setDefaultValue(
        array(
            'status'=>2,
            'cid'=>0,
            'last_comment_timestamp'=> 0,
            'last_comment_name'=> null,
            'last_comment_uid'=> 0,
            'comment_count'=> 0,
)
)
->setDisplayOptions('form', array(
 'type' => 'comment_default',
 'settings' => array(
   'form_location' => 1,
   'default_mode'=> 1,
   'per_page'=>50,
   'anonymous'=> 0,
   'form_location'=>1,
   'preview'=> 1,
   'comment_type'=>'image_comment',
   'locked'=>false,

 ),
 'weight' => 1,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
1
+25

In order to any changes on BaseFieldDefinition effects, you should uninstall/install your module. your syntax seems Ok and I only guest you did some changes after your module( entity) installed.

  • I've already uninstall installed it several times. – cirtrus Nov 8 '16 at 9:29

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.