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