I've build custom entity by extending ContentEntityBase class. It's very similar to the entity from content_entitity_example.

I'd like to allow users to manage fields display the same way they can do it with nodes. Is there a base form class that can generate the form for fields display settings automatically?

The example module provides entity settings form that is derived from Drupal\Core\Form\FormBase however it does not provide any form fields for managing the entity view settings - the form is just empty.

  • 1
    You have to define field ui route in your entity annotation in order for field ui to attach itself to your entity and provide you with their goodies. – user21641 Jan 6 '16 at 19:13
  • @IvanJaros Can you be more specific? I've used field_ui_base_route in entity annotation but that doesn't seem to change anything. Could that might be caused by the fact that I've set fieldable property of my entity to true AFTER it was enabled? – SiliconMind Jan 6 '16 at 19:34
  • Ah, sorry, my bad. This was something else. Extending the \Drupal\Core\Entity\ContentEntityForm should be enough. The \Drupal\Core\Entity\ContentEntityForm::form call entity form display which is responsible for the fields so that should be all. Maybe you haven't declared the edit form in entity annotation? ... no i see you have mentioend the FormBase, yeah, do not use that one, use the ContentEntityForm. – user21641 Jan 6 '16 at 20:07
  • @IvanJaros I'm not asking about entity edit/create forms. I'm asking about entity settings form where you can fields to the entity and manage their view settings. – SiliconMind Jan 7 '16 at 11:41
  • In that case my first answer is the correct one. Do you have entity type entity for your entity - like Node Type is for Node? also that field ui route should point to that entity type entity collection/listing, not to the content entity one. – user21641 Jan 7 '16 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.