diff --git a/category.module b/category.module index 919ad547c035c0d34bc342f90bcdbcb15375c000..202749f5f518c70fbcaa2ce38a02492ec3f826d7 100644 --- a/category.module +++ b/category.module @@ -652,6 +652,16 @@ function category_node_validate(&$node) { } } } + else { + foreach ($categories as $cnid => $category) { + if (empty($category)) { + $container = category_get_container($cnid); + if ($container->required) { + form_set_error("categories][$cnid", t('You must choose a category from %container.', array('%container' => $container->title))); + } + } + } + } } } @@ -1586,10 +1596,10 @@ function category_form_category_submit($form, &$form_state) { $container = category_get_container($form['#node']->category['container']); $container->parents = _category_flatten_parents(category_get_parents($container->cid)); - if (!$container->tags) { - if (empty($form_state['values']['category']['hierarchy']['parents']) || !is_array($form_state['values']['category']['hierarchy']['parents'])) { - $form_state['values']['category']['hierarchy']['parents'] = array(); - } + if (!$container->tags) { + if (empty($form_state['values']['category']['hierarchy']['parents']) || !is_array($form_state['values']['category']['hierarchy']['parents'])) { + $form_state['values']['category']['hierarchy']['parents'] = array(); + } $current_parent_count = count($form_state['values']['category']['hierarchy']['parents']); $previous_parent_count = count($form['#node']->category['parents']);