Development

Changeset 8318

You must first sign up to be able to contribute.

Changeset 8318

Show
Ignore:
Timestamp:
04/05/08 17:12:58 (3 months ago)
Author:
francois
Message:

[doc 1.1] documented batch actions in the generator

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • doc/branches/1.1/book/14-Generators.txt

    r8289 r8318  
    845845            _edit:         ~ 
    846846            _delete:       ~ 
     847          batch_actions: 
     848            _delete:       ~ 
    847849          actions: 
    848850            _create:       ~ 
     
    856858            _delete:       ~ 
    857859 
    858 In a `list` view, there are two action settings: the list of actions available for every object, and the list of actions available for the whole page. The list interactions defined in Listing 14-31 render like in Figure 14-22. Each line shows one button to edit the record and one to delete it. At the bottom of the list, a button allows the creation of a new record. 
     860In a `list` view, there are three action settings: the actions available for every object (`object_actions`), the actions available for a selection of objects (`batch_actions`), and actions available for the whole page (`actions`). The list interactions defined in Listing 14-31 render like in Figure 14-22. Each line shows one button to edit the record and one to delete it, plus one checkbox on each line to delete a selection of records. At the bottom of the list, a button allows the creation of a new record. 
    859861 
    860862Figure 14-22 - Interactions in the `list` view 
     
    862864![Interactions in the list view](/images/book/F1422.png "Interactions in the list view") 
    863865 
    864 In an `edit` view, as there is only one record edited at a time, there is only one set of actions to define. The `edit` interactions defined in Listing 14-31 render like in Figure 14-23. Both the `save` and the `save_and_add` actions save the current edits in the records, the difference being that the `save` action displays the `edit` view on the current record after saving, while the `save_and_add` action displays an empty `edit` view to add another record. The `save_and_add` action is a shortcut that you will find very useful when adding many records in rapid succession. As for the position of the `delete` action, it is separated from the other buttons so that users don't click it by mistake. 
     866In an `edit` view, as there is only one record edited at a time, there is only one set of actions to define (under `actions`). The `edit` interactions defined in Listing 14-31 render like in Figure 14-23. Both the `save` and the `save_and_add` actions save the current edits in the records, the difference being that the `save` action displays the `edit` view on the current record after saving, while the `save_and_add` action displays an empty `edit` view to add another record. The `save_and_add` action is a shortcut that you will find very useful when adding many records in rapid succession. As for the position of the `delete` action, it is separated from the other buttons so that users don't click it by mistake. 
    865867 
    866868The interaction names starting with an underscore (`_`) tell symfony to use the default icon and action corresponding to these interactions. The administration generator understands `_edit`, `_delete`, `_create`, `_list`, `_save`, `_save_and_add`, and `_create`. 
     
    870872![Interactions in the edit view](/images/book/F1423.png "Interactions in the edit view") 
    871873 
    872 But you can also add a custom interaction, in which case you must specify a name starting with no underscore, as in Listing 14-32. 
     874But you can also add a custom interaction, in which case you must specify a name starting with no underscore, and a target action in the current module, as in Listing 14-32. 
    873875 
    874876Listing 14-32 - Defining a Custom Interaction 
     
    900902      $this->redirect('comment/edit?id='.$comment->getId()); 
    901903    } 
     904 
     905Batch actions receive an array of the primary keys of the selected records in the `sf_admin_batch_selection` request parameter. 
    902906 
    903907One last word about actions: If you want to suppress completely the actions for one category, use an empty list, as in Listing 14-34.