Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm generating this form using Settings API:

<form action="options.php" method="post">   
   <?php settings_fields('XX_theme_settings'); do_settings_sections('my_settings'); ?>
   <input type="hidden" name="foo" value="bar" />
   <input name="SubmitButton" type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>" />   
</form>

Validation callbacks $input array returns only 'my_settings' input fields.

How do I access foo (bar) input's value and submit button's name SubmitButton?

This doesn't work for the hidden input:

my_validation($input) {
   $foo = $input['foo'];
}

And when it comes to the submit button I don't even know where to start.

share|improve this question
1  
and $foo = $_POST['foo']? I don't use settings API too often, just a guess. –  ungestaltbar Mar 2 '12 at 23:18
    
Christ, I was trying to do everything within Settings API and didn't even tried $_POST array. Of course you were right, it works! Please repost your comment as an answer so I will be able to accept it. Thank you! :) –  Wordpressor Mar 3 '12 at 0:10

1 Answer 1

up vote 4 down vote accepted

Using $_POST is too low level. Simply give it the same name as your other options. When you options are displayed they should have the names of the form: my_settings[a_particular_option]. For instance:

<input name="my_settings[some_input_option]"/>

Then for your hidden input and submit button:

<input type="hiddden" name="my_settings[foo]" value="bar"/>
<input name="my_settings[SubmitButton]" type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>"/>

In your validation array

my_validation($input) {
   $foo = $input['foo'];
   $submit = $input['SubmitButton'];
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.