Formapi tip.

I was doing some work on a hook_setting() page and needed to do some changes to the returned form before it was past to the default standard system_setting_form_submit() function to save the settings.

I didn't really want to duplicate the system_settings_form_submit(), but if I wanted to add my own _submit() hook the standard one would not be called, and the form would not be saved.

Formsapi is very powerful so I just added the following to the form, and it will now call both my function and the standard function.

$form['#submit'] = array(
    'example_settings_form_submit' => array(),
    'system_settings_form_submit' => array()

Now this will call my function first, and because in the submit() hook passes $form_values by reference, the changes that are made to it are past to the default function. 

my projects: 


That's an awesome tidbit...

I needed to do that just a few hours ago to make sure that a module of mine rebuilds some cached data whenever the settings change. I was about to implement my own settings page from scratch, but this will save me the work. Thanks!

Do you actually get the

Do you actually get the $form_values argument doing it this way? From my reading of the code I thought you had to put that reference in yourself. Unless it's already been done.

 In any case, a better way is to use array_merge().



$form['#submit'] = array_merge(array('example_settings_form_submit' => array()), $form['#submit');



 That way if some other hook_form_alter has added their #submit, you don't blow it away.

me too

og_settings() does this too. in fact, i stumbled into a fapi design problem which was later fixed. glad you were able to implement this cleanly




Speaking of formsapi... ;-), I was wondering if there is a plan for the formsapi conversion of filestore2, i.e. to coincide with the imminent release of Drupal 4.7.


Many thanks,



I know the submit function function example_settings_form_submit($form_id, &$form) for instance, is being called correctly, and I can change the array variables. The trouble is, the variables/array is not being saved. What exactly should I include in this function to get the node to save correctly?