Revision 2cfed42f
Von Moritz Bunkus vor etwa 13 Jahren hinzugefügt
SL/Controller/Helper/ParseFilter.pm | ||
---|---|---|
146 | 146 |
customer. L<Rose::DB::Object> alloes you to search for these by filtering them prefixed with their table: |
147 | 147 |
|
148 | 148 |
query => [ |
149 |
customer.name => 'John Doe',
|
|
150 |
department.description => [ ilike => '%Sales%' ],
|
|
151 |
orddate => [ lt => DateTime->today ],
|
|
149 |
'customer.name' => 'John Doe',
|
|
150 |
'department.description' => [ ilike => '%Sales%' ],
|
|
151 |
'orddate' => [ lt => DateTime->today ],
|
|
152 | 152 |
] |
153 | 153 |
|
154 | 154 |
Unfortunately, if you specify them in you form as these strings, the form |
... | ... | |
171 | 171 |
|
172 | 172 |
=over 4 |
173 | 173 |
|
174 |
=item parse_amount \%FILTER, [ %PARAMS ]
|
|
174 |
=item C<parse_filter \%FILTER, [ %PARAMS ]>
|
|
175 | 175 |
|
176 | 176 |
First argument is the filter from form. It is highly recommended that you put |
177 | 177 |
all filter attributes into a named container as to not confuse them with the |
... | ... | |
181 | 181 |
example if you search for L<Order>s, this input will search for those with a |
182 | 182 |
specific L<Salesman>: |
183 | 183 |
|
184 |
[% L.select_tag('filter.salesman.id', ... |
|
184 |
[% L.select_tag('filter.salesman.id', ...) %]
|
|
185 | 185 |
|
186 | 186 |
Additionally you can add modifier to the name to set a certain method: |
187 | 187 |
|
188 |
[% L.input_tag('filter.department.description:substr::ilike' ...
|
|
188 |
[% L.input_tag('filter.department.description:substr::ilike', ...) %]
|
|
189 | 189 |
|
190 |
This will add the "% .. %" wildcards for substr matching in sql, and add an C<[
|
|
191 |
ilike => $value ]> block around it to match case insensitively.
|
|
190 |
This will add the "% .. %" wildcards for substr matching in SQL, and add an
|
|
191 |
C<< ilike => $value >> block around it to match case insensitively.
|
|
192 | 192 |
|
193 | 193 |
As a rule all value filters require a single colon and must be placed before |
194 | 194 |
match method suffixes, which are appended with 2 colons. See below for a full |
... | ... | |
209 | 209 |
|
210 | 210 |
=item Laundering filter |
211 | 211 |
|
212 |
Unfortunately Template cannot parse the postfixes if you want to rerender the |
|
213 |
filter. For this reason all colons filter keys are by default laundered into |
|
214 |
underscores. If you don't want this to happen pass C<no_launder => 1> as a |
|
215 |
parameter. A full select_tag then loks like this: |
|
212 |
Unfortunately Template cannot parse the postfixes if you want to |
|
213 |
rerender the filter. For this reason all colons filter keys are by |
|
214 |
default laundered into underscores. If you don't want this to happen |
|
215 |
pass C<< no_launder => 1 >> as a parameter. A full select_tag then |
|
216 |
loks like this: |
|
216 | 217 |
|
217 | 218 |
[% L.input_tag('filter.price:number::lt', filter.price_number__lt) %] |
218 | 219 |
|
... | ... | |
227 | 228 |
|
228 | 229 |
=item date |
229 | 230 |
|
230 |
Parses the input string with DateTime->from_lxoffice
|
|
231 |
Parses the input string with C<< DateTime->from_lxoffice >>
|
|
231 | 232 |
|
232 | 233 |
=item number |
233 | 234 |
|
234 |
Pasres the input string with Form->parse_amount
|
|
235 |
Pasres the input string with C<< Form->parse_amount >>
|
|
235 | 236 |
|
236 | 237 |
=item percent |
237 | 238 |
|
238 |
Parses the input string with Form->parse_amount / 100
|
|
239 |
Parses the input string with C<< Form->parse_amount / 100 >>
|
|
239 | 240 |
|
240 | 241 |
=item head |
241 | 242 |
|
... | ... | |
277 | 278 |
following will not work as you expect: |
278 | 279 |
|
279 | 280 |
# does not work! |
280 |
L.input_tag('customer.name:substr::ilike', ... |
|
281 |
L.input_tag('invoice.customer.name:substr::ilike', ... |
|
281 |
L.input_tag('customer.name:substr::ilike', ...)
|
|
282 |
L.input_tag('invoice.customer.name:substr::ilike', ...)
|
|
282 | 283 |
|
283 | 284 |
This will sarch for orders whoe invoice has the _same_ customer, which matches |
284 | 285 |
both inputs. This is because tables are aliased by their name and not by their |
Auch abrufbar als: Unified diff
Dokumentation kompatibler mit pod2html und so gemacht