Widget form not saving radio button option
-
I’ve recently created a new widget but I’m having a problem with the radio button options in my form function. I can’t get the saved option to show up in the config form where you go to configure the widget. If you choose an option and save, the correct setting does get saved to the database. However, when you go back to re-configure it doesn’t show either radio button selected.
Here is my code for the radio button in my form function of my widget class:
<p>
<label for="<?php echo $this->get_field_id( 'showCategories' ); ?>">Show categories:</label>
<input type="radio" name="<?php echo $this->get_field_name( 'showCategories' ); ?>" value="1"<?php echo $instance['showCategories'] == 1 ? ' checked' : ''; ?>" /> Yes
<input type="radio" name="<?php echo $this->get_field_name( 'showCategories' ); ?>" value="0"<?php echo $instance['showCategories'] == 0 ? ' checked' : ''; ?>" /> No
</p>
-
You did not specify a blog address or reason for posting when you created this topic.
This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.
If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.
If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.
This is an automated message.
-
Forms are not an approved code at WordPress.com and will always be stripped out, except the Contact Form.
-
See > http://en.support.wordpress.com/code/ to find the limitations here at wordpress.com
- The topic ‘Widget form not saving radio button option’ is closed to new replies.