Using multiple settings_fields() on 1 settings page

I have been struggling with this one for about a week now. I would like to have 2 variables available on a settings page, but I cannot figure out how to do this using the Settings API.

Perhaps there is a better way to do this. What I am trying to do is have one variable that stores a list of sortable values which I am outputting in a table and using jQuery sortable to allow the user to sort. But I also have some related options (such as title for the section) that are not sortable, so I want to store them in a separate variable and output them normally using add_settings_field which is where things break down. The minute I add a second settings_fields() call in the callback function below, it will allow me to set the options covered by the last settings_fields() call. Obviously since the settings_fields() adds the nonce, action, and option_page fields tot he page the second one is overriding the first call.

Read More

So how do I include a second options variable on a settings page?

Here is my code so far:

Adding the submenu page:

    add_submenu_page(
        'crest_feed_admin',
        'Gallery View Options',
        'Gallery View',
        'manage_options',
        'crest_feed_admin_gallery_view',
        'crest_feed_menu_gallery_view_page'
    );

Register the settings variable:

register_setting( 'crest-feed-gallery-group', 'crest_gv_options' );  // need to add validation!

Callback function for submenu page creation:

function crest_feed_menu_gallery_view_page() {

    $options = get_option('crest_gv_options');
    ?>
    <div class="wrap">
        <div class="sir-crest-plugin-icon">
            <img src="<?php echo CREST_PLUGIN_DIR . '/images/admin-icon-large.png'; ?>" height=32 width=32 />
        </div>
        <h2><?php _e('Gallery List Items & Options'); ?></h2>
        <form method="post" action="options.php"> 

        <?php
        submit_button('Save Gallery View Options'); 
        settings_fields( 'crest-feed-gallery-group' ); 

        crest_drag_and_drop($options, 'gv');  // this function creates the table of sortable values

        submit_button('Save Gallery View Options'); 

        ?>
        </form>
    </div>
    <?php   
}

Related posts