Search code examples
drupaldrupal-7

Drupal 7 which hook is called when user updates any field in configuration


I am new to Drupal, I am looking for a hook that is called when user update the value of any field in configuration area so that I could update it on other locations using custom module.


Solution

  • As I understand your question you wish to write a custom module that makes changes to other data in the CMS upon submission of a form, using data from that particular form.

    To do this you could use hook_form_FORM_ID_alter (see the official Drupal API docs for details) in your .module file to specify a new submission callback function like so:

    function YOURCUSTOMMODULENAME_form_FORM_ID_alter(&$form, &$form_state, $form_id)
    {
         $form['#submit'][] = 'my_callback_function';
    }
    
    function my_callback_function($form, &$form_state)
    {
         //Whatever code you want to execute here to update other fields
    }
    

    The code above targets a specific form by id, but you can use the more generic hook_form_alter to target all forms. See the API docs for more details on which order these form hooks fire in and what parameters they each need.