function search_api_page_forms in Search API Pages 7
Implements hook_forms().
File
- ./
search_api_page.module, line 178 - Generate search pages using Search API indexes.
Code
function search_api_page_forms($form_id, $args) {
// Check whether the given form ID matches our pattern for dynamically
// generated form IDs.
$prefix = 'search_api_page_search_form_';
$prefix_length = strlen($prefix);
if (substr($form_id, 0, $prefix_length) != $prefix) {
return array();
}
// Make sure we do have a page as the first argument.
if (!$args || !$args[0] instanceof Entity) {
return array();
}
// Retrieve the search page machine name from the form ID and compare it with
// the one from the page in the arguments. Also check the page is actually
// enabled.
$page_id = substr($form_id, $prefix_length);
$page = $args[0];
if ($page->machine_name == $page_id && $page->enabled) {
return array(
$form_id => array(
'callback' => 'search_api_page_search_form',
'callback arguments' => array(),
),
);
}
return array();
}