ReStructured Text Infrastructurewiki.typo3.orgOfficial Documentation

TCA_documentation_group_and_inline_filters.txt

Ingmar Schlecht, 2012-05-06 08:22

Download (3 kB)

 
1
2
--------------------------------------------------------------------------------
3
New property for ['columns'][field name]['config'] / TYPE: "group":
4
--------------------------------------------------------------------------------
5
filter
6
7
Datatype:
8
	array
9
10
Description:
11
12
	Possibility to define filters for item values (internal_type=db only!).
13
	
14
	This is useful when only foreign records matching certain criteria should be allowed to be used as values in the group field. The values are filtered in the Element Browser as well as during processing in TCEMain. Filter userFuncs should have two input arguments ($parameters and $parentObject). The first argument ($parameters) is an array with the parameters of the filter as configured in the TCA, but with the additional parameter "values", which contains the array of values which should be filtered by the userFunc. The function must return the filtered array of values.
15
	
16
	Multiple filters can be defined, and an array of configuration data for each of the filters can be supplied.
17
	
18
	'filter' => array (
19
		array(
20
			'userFunc' => 'EXT:myext/class.tx_myext_filter.php:tx_myext_filter->doFilter',
21
			'parameters' => array(
22
				// optional parameters for the filter go here
23
 			),
24
		),
25
		array(
26
			'userFunc' => 'EXT:foo/class.tx_foo_filter.php:tx_foo_filter->myFilter',
27
			'parameters' => array(
28
				// optional parameters for the filter go here
29
			),
30
		),
31
	),
32
	
33
	Example:
34
		Say you have a "person" table with fields "gender" (radio buttons) as well as "mother" and "father" (both group fields with relations to the same table.
35
		
36
		Now, in the field "mother" it should certainly only be possible to create relations to female persons. In that case, you could use the filter functionality to make sure only females can be selected  in that field. 
37
		
38
		In that case, the field configuration for the "mother" field would look like:
39
40
		'mother' => array (		
41
			'label' => 'Mother',	
42
			'config' => array (
43
				'type' => 'group',	
44
				'internal_type' => 'db',	
45
				'allowed' => 'tx_myext_person',	
46
				'size' => 1,	
47
				'filter' => array (
48
					array(
49
						'userFunc' => 'EXT:myext/class.tx_myext_filter.php:tx_myext_filter->doFilter',
50
						'parameters' => array(
51
							'evaluateGender' => 'female',						),
52
					),
53
				),
54
			)
55
		),
56
	
57
	The corresponding filter class would look like:
58
59
		class tx_myext_filter {
60
		
61
			public function doFilter(array $parameters, $parentObject) {
62
				$fieldValues = $parameters['values'];
63
				
64
				// do the filtering here
65
				...
66
				
67
				return $fieldValues;
68
			}
69
		}
70
71
72
Scope:
73
	Display / Proc.
74
	
75
	
76
--------------------------------------------------------------------------------
77
New property for ['columns'][field name]['config'] / TYPE: "inline":
78
79
filter
80
81
Datatype:
82
	array
83
84
Description:
85
86
	Possibility to define filter userFuncs to filter out child items.
87
	
88
	This is useful in special scenarios when used in conjunction with a foreign_selector where only certain
89
	foreign records are allowed to be related to.
90
	
91
	For further documentation of this feature, see the "filter" documentation under TYPE: "group".
92