-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformfilterapi.api.php
70 lines (65 loc) · 1.62 KB
/
formfilterapi.api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* @file
* Hooks provided by the Formfilterapi module.
*/
/**
* Form to filter data.
*
* Via this hook possible to change variables before processing their module.
* And add your form elements, for filtering.
*
* @param string $operation
* Name of the operation is executed.
* @param string $session_name
* The unique session name.
*
* @return array
* Form with filter elements.
*/
function hook_formfilterapi($operation, $session_name) {
switch ($operation) {
case 'filters':
if ($session_name == 'test') {
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#where' => array('like' => 'n.title'),
);
$form['promote'] = array(
'#type' => 'checkbox',
'#title' => t('Promoted to front page '),
'#where' => array('expression' => '(n.promote = :value)'),
);
return $form;
}
break;
}
}
/**
* Alter filters for hook_formfilterapi().
*
* @param array $filters
* Filters from hook_formfilterapi().
* @param string $session_name
* The unique session name.
* @param string $operation
* Name of the operation is executed.
*/
function hook_formfilterapi_alter(&$filters, $session_name, $operation) {
switch ($operation) {
case 'filters':
if ($session_name == 'test') {
$filters['sticky'] = array(
'#type' => 'select',
'#title' => t('Sticky at top of lists'),
'#options' => array(
'1' => t('Yes'),
'0' => t('No'),
),
'#where' => 'n.sticky',
);
}
break;
}
}