"Undefined index" error when saving empty array with checkboxes
-
I have
WP_DEBUGmode on my local WordPress install for a plugin I am developing.In my plugin settings page, I have a list of checkboxes that store the value into an array. While the functions work as expected, whenever I uncheck all of the checkboxes and save those changes I get the Notice: Undefined index: remove_field (line 19) error showing up only when I have debug mode on. Below is the source:
https://github.com/factmaven/disable-blogging/blob/dev/includes/settings-profile.php
From doing research online for a similar error, I see that the recommendation is to wrap
$_POST['remove_field']with anisset. However, this does not store the values form the checkboxes in the plugin settings.As mentioned above, this error shows up only when all of the checkboxes are unchecked and saved. It looks like there is an issue when saving empty values in the array. Although the plugin settings works as expected, I’d like to fix this.
The topic ‘"Undefined index" error when saving empty array with checkboxes’ is closed to new replies.