最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp admin - Form input values are empty after submit

programmeradmin6浏览0评论

I'm trying to build a settings page for my WordPress theme. I have created the following form which includes repeatable input fields. Everything is working except when I submit the form and refresh the page it shows me for example 3 inputs but with empty values. (Values are in the DB)

function fr_render_form() { ?>
        <div class="wrap">

                <div class="icon32" id="icon-options-general"><br></div>
                <h2>Options</h2>

                <form method="post" action="options.php">
                        <?php $options = get_option('fr_options'); ?>

                        <table class="form-table">

                               <tr>
                                <td>
                                    <a class="repeatable-add button" href="#">+</a>
                                    <ul id="tracks-repeatable-repeatable" class="custom_repeatable">
                                 <?php 
                                  if ( ! empty( $options ) ) {
                                        $i = 1;
                                        foreach( $options as $option ) {
                                            ?> <li>
                                            <input type="text" name="fr_options[txt_<?php echo $i; ?>]" value="<?php echo $options['fr_options'.$i]; ?>" />
                                            <a class="repeatable-remove button" href="#">-</a>
                                            </li>
                                            <?php
                                            $i++;
                                        }
                                    } else {
                                        ?> <li>
                                        <input type="text" name="fr_options[txt_1]" value="<?php echo $options['txt_1']; ?>" />
                                         <a class="repeatable-remove button" href="#">-</a>
                                        </li>
                                        <?php
                                    } ?>
                                    </ul><a class="repeatable-add button" href="#">+</a> 
                                </td>
                            </tr>

                        </table>
                        <p class="submit">
                        <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
                        </p>
                </form>

        </div>
        <?php  
}

Any ideas what's wrong?

Thank you

发布评论

评论列表(0)

  1. 暂无评论