Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The hook_form_alter implementation is executed on forms where it should not have. hook_form_alter is invoked for all the forms, but we only need to alter the node form at this point.
Proposed resolution
Rename onlyone_form_alter function to onlyone_form_node_form_alter (implementing hook_form_BASE_FORM_ID_alter), that function is guaranteed to be called only node edit/add forms. An we can also access the full node object and its type (even on node-add forms) and eliminate the use of the substr function.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #3
adriancidComment #6
adriancid