I created custom entity, added basefields in class and now I want to add fields. I know I could add them with UI but wondering how to do that with code. Is the proper way to add .yml files in config/install and when module is installed this config should be too or do I need to use hooks to add fields and .yml part doesnt work in this cases?

  • If the fields are important enough to come with the module, is there are particular reason you've chosen not to implement them as base fields? – Clive Sep 13 '18 at 12:14
  • 1
    Yes, the main reason for creating custom entity types is to define exactly what you need as base field. Anything that can be a configurable field can be a base field too. Other than that you also already answered your own question, fields, like any other configuration, would be added to config/install, yes. – Berdir Sep 13 '18 at 22:29
  • @Clive there is no reason, I am doing this for learning purposes and what can and can't be done. – Marko Blazekovic Sep 14 '18 at 7:15

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.