Problem/Motivation
When using the search bar provided by search_api_page, both the block and the page use the same form class. As a result, all generated forms share the same form ID.
This makes it difficult to reliably identify which form is being rendered (block vs page) when implementing hook_form_alter() or similar form-alter hooks, since there is no contextual distinction between them.
Steps to reproduce
- Install the search_api_page module.
- Create a search page.
- Place a search block on the same page. (Eg. You can have the searchbox in your header)
- Attempt to alter only one of the forms (page or block) using a form alter hook.
Proposed resolution
Since the form builder already accepts parameters, pass an additional context value (for example, indicating whether the form is rendered as a block or as a page).
This context would allow developers to reliably identify the origin of the form and apply targeted alterations when using form alter hooks.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork search_api_page-3568942
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #5
karlshea