function views_handler_filter_tag_font_tid::validate_tag_strings in @font-your-face 7
Same name and namespace in other branches
- 6.2 views/views_handler_filter_tag_font_tid.inc \views_handler_filter_tag_font_tid::validate_tag_strings()
- 7.2 modules/fontyourface_ui/views/views_handler_filter_tag_font_tid.inc \views_handler_filter_tag_font_tid::validate_tag_strings()
Validate the user string. Since this can come from either the form or the exposed filter, this is abstracted out a bit so it can handle the multiple input sources.
2 calls to views_handler_filter_tag_font_tid::validate_tag_strings()
- views_handler_filter_tag_font_tid::exposed_validate in views/
views_handler_filter_tag_font_tid.inc - Validate the exposed handler form.
- views_handler_filter_tag_font_tid::value_validate in views/
views_handler_filter_tag_font_tid.inc - Validate the options form.
File
- views/
views_handler_filter_tag_font_tid.inc, line 215 - Views handler.
Class
- views_handler_filter_tag_font_tid
- Filter by tag id. Largely copied from views_handler_filter_term_node_tid.inc
Code
function validate_tag_strings(&$form, $values) {
if (empty($values)) {
return array();
}
// if
$tids = array();
$args = array();
$results = array();
foreach ($values as $value) {
$missing[strtolower($value)] = TRUE;
$args[] = $value;
}
// foreach
if (!$args) {
return;
}
// if
$result = db_select('fontyourface_tag', 't')
->condition('t.name', $args, 'IN')
->execute();
foreach ($result as $tag) {
unset($missing[strtolower($tag->name)]);
$tids[] = $tag->tid;
}
// foreach
if ($missing) {
form_error($form, format_plural(count($missing), 'Unable to find tag: @tags', 'Unable to find tags: @tags', array(
'@tags' => implode(', ', array_keys($missing)),
)));
}
// if
return $tids;
}