Changeset 1342
- Timestamp:
- 05/11/06 15:21:52 (3 years ago)
- Files:
-
- trunk/doc/book/content/generator.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/doc/book/content/generator.txt
r1193 r1342 343 343 The resulting filter will allow text-based search on an author name (where the `*` character can be used as a joker), and the selection of the comments related to a given article by a choice in a selection list. As for regular `object_select_tag()`, the options displayed in a select are the ones returned by the `->toString()` method of the related class (or the primary key if such a method doesn't exist). 344 344 345 Just like you use partial fields in lists, you can also use partial filters to create a filter that symfony doesn't handle on its own. For instance, imagine a `state` field that may only contain 2 values (`open` and `closed`), but for some reason you store those values directly in the field instead of using a table relation. A simple filter on this field (of string type) would be a text-based search, but what you want is probably a select with a list of values. That's quite easy to achieve with a partial filter: 346 347 list: 348 filters: [date, _state] 349 350 Then, in `templates/_state.php`: 351 352 [php] 353 <?php echo select_tag('filters[state]', options_for_select(array( 354 '' => '', 355 'open' => 'open', 356 'closed' => 'closed', 357 ), isset($filters['state']) ? $filters['state'] : '')) ?> 358 359 Notice that the partial has access to a `$filters` variable, whiwh is very useful to get the current value of the filter. 360 345 361 ### Sort 346 362 … … 351 367 [php] 352 368 <?php echo link_to('Comment list by date', 'comment/list?sort=date&type=desc' ) ?> 369 370 You can also define a default sort field for the `list` view directly in the `generator.yml`: 371 372 list: 373 sort: date 374 375 Or, if you want to specify the sort order: 376 377 list: 378 sort: [date, desc] 353 379 354 380 ### Pagination