Timeline for How to add custom fields and display settings to built-in content types via custom module install?
Current License: CC BY-SA 3.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 20, 2016 at 20:33 | comment | added | Berdir | Having the fields in exported config is fine, nothing wrong with that IMHO. They have explicit dependencies and won't allow you to install if that node type isn't there. But you also need form/view display information, and those are stored per node type and view/form mode, so you can't just provide it as config, you need to add it as code with hook_install(). See drupal.stackexchange.com/questions/222260/… for example. | |
Dec 20, 2016 at 12:53 | comment | added | marcvangend | Ah, I see. In that case I think YML isn't sufficient, because you need some logic to check that the node type exists, and the field does not. You probably need to implement hook_install in your module and programmatically add the field to the node. Here is a post describing how to do that, but I'm not adding it to my answer because I didn't test if it really works. | |
Dec 20, 2016 at 10:44 | comment | added | Manuel Rodriguez | Thanks for the answer, but in this case I want my module when installing to be able to create the fields into the nodes, I don't want the user to create the field, or manage the field himself. Is that possible? | |
Dec 20, 2016 at 10:12 | history | answered | marcvangend | CC BY-SA 3.0 |