Agaric Design Collective

How to break Drupal's system_settings_form submit handling without trying

By Benjamin Melançon
on 11 Dec
2 comments

Key words and phrases

why drupal submit form not working administration form settings not saving return system_settings_form($form) isn't system settings form not doing anything

Tags

Description

AAAAAAUUUUUggggGGGGGHHHHHHhhhRRrrrr

So class, the lesson today is that if you have system_settings_form($form) form (meaning masic submit and creating variables is handled automatically), you CANNOT have a helper submit function with the same name plus _submit.

OK, you already knew that.

Additionally -- and here's where the screams come in -- you cannot have it with a similar name where the whole thing is prefixed with an underscore, either.

Oh, never mind. Agaric had *both* functions beginning with an underscore:

function _userreference_access_admin()

function _userreference_access_admin_submit($form_id, &$form_values)

Don't let this happen to you! Tell your children!

$form['#submit']['_userreference_access_admin_submit_helper'] = array();
function _userreference_access_admin_submit_helper($form_id, &$form_values)

That's better. Um, no, it's not.

OK. Apparently Drupal 5 has no way to use the drupal core system settings submit function and an additional custom one as a supplement, and I was delusional just to try, let alone to think it worked for a moment.

You can still name your own submit function, but understand it will override and you have to save all your values yourself, counting on

No free variable saving if you want to do anything else.

Now you know.

Resolution

If you want to take over part of submit handling for a system_settings_form handled form, you have to take over all the submit handling.

Or can you have element-level submit handlers? I guess so. But whatever. Using set_variable ain't that hard.

 

Solution

I found the answer to this problem at http://drupal.org/node/58689

You just have to manually add the default submit handler to the #submit array:

$form['#submit']['my_custom_settings_submit_helper'] = array();
$form['#submit']['system_settings_form_submit'] = array();

Posted by Ben Shell (not verified) on Wed, 2008-11-05 18:24
Nice!

Thanks!

Posted by Benjamin Melançon on Wed, 2008-11-05 18:57
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.