I am wondering what is the cleanest way to customize the core node edit form fields like the publishing and menu options fields?
They do not appear in the Manage fields tab, otherwise I would be able to organize them using modules like Display Suite, Field Groups, and either Conditional Fields or Field Conditional States as I do with other fields.
Here are a few example of things I would like to do (I achieved such things in the past with Drupal 6 by altering the form array, but I want to avoid this now since this was more complex, less maintainable and with not enough separation between the presentation and application logic):
- Adding supplementary fields to existing tabs: My site has news articles which can be promoted on the front-page (using the standard Drupal checkbox) and/or appear on some other pages (using multiple Entity Reference fields). All these control should be grouped together since they all are publishing options from the end-user perspective.
- Core fields availability dynamically depends on custom fields: A user can choose to link the node title and the node's menu link title so changing one will alter the other automatically. In such case the field asking to enter the menu link title must be hidden. However, it must show-up if for some reason the user choose to unlink them and set different values for both titles.
- Core fields availability dynamically depends on other core fields: Some content can be created either with no menu item, in which case it can only be referenced by other nodes, or with a menu item, in which case the end-user can choose to publish or unpublish it. The Published option should therefore be available only when the user chose to create a menu item since it is not relevant otherwise for this content-type.
I tried with Display Suite extra's Extra fields feature, but it only adds the fields on the Manage display tab, and not the Manage fields as I need.
My current solution is to add standard custom fields to the node, hide the default ones and code the logic in hook_node_presave()
for instance, but I do not know if there any cleaner solution?