Rename hook_form_BASE_FORM_ID_alter to hook_base_form_FORM_ID_alter

Created on 1 February 2013, about 12 years ago
Updated 13 February 2025, 10 days ago

The form alteration is really flexibile in D7 with the new hooks and especially in combination with hook_forms hook but in some cases there is a problem with hook_form_FORM_ID_alter overlapping with hook_form_BASE_FORM_ID_alter.

For example: I have a user_profile_form displayed as mymodule_myuser_profile_form using hook_forms. And let's say I want to hide all unnecessary fields from the(original) user_profile_form via mymodule_form_user_profile_form_alter, but only in that form(not it's instances). Then I want to display all fields of the user_profile_form within my mymodule_myuser_profile_form function but let's say this time I'll hide just one particular field. So I'll use the mymodule_form_mymodule_myuser_form_alter to do that.

BUT here is the issue: all the fields are already hidden because mymodule_form_user_profile_form has been already run by Drupal since it thinks it is a hook_form_BASE_FORM_ID_alter insted of hook_form_FORM_ID_alter so I need to put unncessary logic into the mymodule_form_mymodule_myuser_profile_form OR add #form_id detection clause into the mymodule_form_user_profile_form_alter function.

So what I propose is to rename the hook_form_BASE_FORM_ID_alter to hook_base_form_BASE_FORM_ID_alter so it is clear to us and especially to Drupal when we actually want to alter the original form and when to alter form just byt it's ID(hook_form_FORM_ID_alter).

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

forms system

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024