Organizes hook_form_alter() code into separate files and adds the ability to alter forms based on a user's roles.

Moving the hook_form_alter() code into separate files makes it easier for developers to re-use their code. This module eliminates the need to create custom form altering modules for individual projects. Instead of a custom module developers can simply copy existing form_alter file code to new project and easily change it.

The ability to alter forms based on a user's roles allows developers to hide, show, or alter form elements that may or may not be needed for a specific role.

For example, an 'editor' should be able to update the general text on the 'Site information' form but they should not be able to change site configuration settings like the 'Anonymous user' and 'Default front page'.

Users with 'administer form helper alter' permission will see a 'Form helper' fieldset appended to every form. This fieldset will contain the paths to all the possible hook_alter_form() files with automatically generated sample code. To implement a hook_form_alter() a developer will need to create the specified files with the correct code.

The base hook function names and default file paths are:

  • hook_form_FORM_ID_alter(); => sites/all/form_helper_alter/FORM_ID.inc
  • hook_form_ROLE_ID_FORM_ID_alter(); => sites/all/form_helper_alter/ROLE_ID/FORM_ID.inc
Related Hooks Similar Modules
  • Form alter: Provides a UI for altering forms. (Under Development)

Functions

NameDescription
form_helper_alter_form_alterImplementation of hook_form_alter().
form_helper_alter_form_alter_submitSubmission handler to remove form_helper_alter_fieldset.
form_helper_alter_menuImplementation of hook_menu().
form_helper_alter_permImplementation of hook_perm().
_format_helper_get_form_alter_hooksCreate and cache hooks for a form base on the $form_id
_form_helper_alter_append_elements_to_formAppend form helper hook paths with sample code to a form.
_form_helper_alter_append_form_alter_fieldsetAppend hook_form_alter() fieldset with elements to a parent fieldset.
_form_helper_alter_execute_hookExecute form_helper_form_alter() by loading appropriate file and executing the hook function.
_form_helper_alter_format_form_alter_codeFormat hook_form_alter() code as an easy to edit list of array properties.
_form_helper_alter_format_form_alter_code_recursiveRecurse through the $form variable and create an easy to edit string.