As I was thinking through this yesterday, I wanted to see the code that populated the $errors array, because I felt certain that was the core of the issue.
Here's the final working code that you posted:
PHP Code:
$errors = array();
$required_fields = array('menu_name', 'position', 'visible', 'content');
foreach($required_fields as $fieldname) {
if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && !is_numeric($_POST[$fieldname]))) {
$errors[] = $fieldname;
}
}
You should compare the fourth line of this code against what was in use when you first posted this issue. I expect that initially it was just doing "!isset($_POST[$fieldname]) || empty($_POST[$fieldname]) " which gave a false positive for values that evaluated to zero.
Also, while the [ code ] and [ /code ] tags will make any block of text stand out, the [ php ] and [ /php ] tags (without the spaces) will apply syntax highlighting to php code (which, incidentally, can be utilized as a simple, free syntax checker: just "Go Advanced", paste your code and wrap it in "php" blocks, and then "Preview Post.")