Submitting Option Choice From An Option Page
I’m trying to create my first plugin and have gotten as far as creating the page, adding it to the menu, showing a drop down box and showing a submit button.
Howsomever, I cannot get the form to save the value, or update an existing option.
As a non-coder, I have gotten myself lost trying to understand the codex and the api, including being unable to copy and paste the options page examples that are shown and make them work. If you can help me, please, please jump right in and tell me what to do.
Here’s what I have for a form so far …
// Plugin title and some other stuff ?> <!-- Opening The Form --> <div> <form method="post" action="options.php"> <?php settings_fields( 'products' ); ?> <!-- Inserting The Dropdown Box On The Page And Inside The Page Function --> <!-- Using selected() instead --> <select name="options[products]"> <option value="unicykes" <?php selected( $options['products'], unicykes ); ?>>unicykes</option> <option value="bikes" <?php selected( $options['products'], bikes ); ?>>bikes</option> <option value="trikes" <?php selected( $options['products'], trikes ); ?>>trikes</option> </select> <?php do_settings_fields( 'products' ); ?> <p> <input type="submit" value="<?php _e( 'Save Options', 'products' ); ?>" /> </p></form> </div> <?php } // End of page ?>
- The topic ‘Submitting Option Choice From An Option Page’ is closed to new replies.