1 node.module node_search_admin_validate($element, &$form_state)

Element validation callback for the search admin form.

File

core/modules/node/node.module, line 1458
The core module that allows content to be submitted to the site.

Code

function node_search_admin_validate($element, &$form_state) {
  // Turn the saved value into an unindexed array.
  $form_state['values']['node_types'] = array_keys(array_filter($form_state['values']['node_types']));

  // Ensure at least one value was checked.
  if (empty($form_state['values']['node_types'])) {
    form_set_error('node_types', t('Please select at least one content type to search, or completely disable searching content.'));
  }
  // If all types are checked, save an empty array indicating all types are enabled.
  elseif (count($form_state['values']['node_types']) === count(node_type_get_names())) {
    $form_state['values']['node_types'] = array();
  }
}