0

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?

  • What you want to achieve exactly from this? as these fields are already customise at content type edit page. – Nikhil Banait Oct 14 '15 at 16:36
  • @NikhilBanait: The "customization" offered by the content-type edit page is rather limited. I've updated my question to include some concrete example of what I would like to achieve. – WhiteWinterWolf Oct 15 '15 at 9:07
0

Issue solved mainly thank to the Renderable elements module.

It adds the core node edit form's vertical tabs and their content to the usual Manage fields tab, allowing any kind of customization (adding, removing, reordering tabs and fields, the tabs properties can even be turned into horizontal tabs if one needs this, etc.).

There is a very good short video introducing this module's main features.

The only limitation is that the way this module alter the forms may cause incompatibilities with other modules. On my side I just noticed minor issues with no impact to the end-user:

  • The standard checkbox "Provide a menu link" does not hide automatically the other menu related options depending on its state, this is a non-issue for me since I precisely wanted to customize this behavior,
  • Modules like Conditional Fields do not detect yet the supplementary fields added by the Renderable Elements module. The few States API effects directly involving these fields might need to be coded specifically (Conditional Fields offers an option to manually define the jQuery selector to be used, I didn't tried yet if this could be a reliable workaround for this issue),
  • Other modules which were already programmatically altering the default vertical tabs may be confused and become unable to alter the tabs anymore. For instance, Fast Permissions Administration does not add anymore its "Manage Permissions" link in the Publishing options vertical tab.

The good news is that this module is fully compatible with Display Suite and Field Group. The vertical tabs and its components can be moved to any Display Suite's region, but more importantly the vertical tabs content can be organized in any kind of group you like (<DIV> markers, (collapsible) fieldsets, other tabs, etc.).

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.