Saturday, 7 September 2013

Wordpress plugin settings page - checkbox wont stay checked

Wordpress plugin settings page - checkbox wont stay checked

Small issue, I'm sure its a simple fix. My checkbox field on a plugin page
I wrote wont stay checked. The data is being saved, but the checkbox does
not reflect the current stored value (checked).
Here is my function code:
public function jo_checkbox_del_setting()
{
echo "<input id='jo_checkbox_del'
name='jo_plugin_options[jo_checkbox_del]' type='checkbox'
value='{$this->options['jo_checkbox_del']}' />";
}
and the add_settings_field code:
add_settings_field('jo_checkbox_del', 'Hide Delete Button: ', array($this,
'jo_checkbox_del_setting'), __FILE__, 'jo_main_section');
Any help is greatly appreciated!
as you can see in the picture, the value is 1 which is checked, but the
checkbox never stays checked after refresh.

No comments:

Post a Comment