I'm using have_fields to loop through an array and create a list of checkboxes. Everything seems to be working great, except that the checkboxes aren't consistently showing as "checked" on the backend. Here's the code I'm using:
<?php $items = array( 'bio', 'youtube', 'articles', 'learn-more', 'testimonials', 'twitter', 'custom', ); ?> <p> <?php while ($mb->have_fields('t_enabled_widgets', count($items))): ?> <?php $item = $items[$mb->get_the_index()]; ?> <input type="checkbox" name="<?php $mb->the_name(); ?>" value="<?php echo $item; ?>"<?php $mb->the_checkbox_state($item); ?>/> <?php echo ucwords(str_replace("-", " ", $item )); ?><br/> <?php endwhile; ?> </p>
For example, when I check the first 4 boxes, (Bio, Youtube, Articles, and Learn More), all is well. When I check the 5th, it saves to the database, but when the page reloads, it's unchecked. This is obviously a problem because when you then "Update" the page again it's submitted as a blank value.