Getting batch_action functionality in Symfony 1.0

Posted by Alex Ciminian on Stack Overflow See other posts from Stack Overflow or by Alex Ciminian
Published on 2010-03-19T12:45:50Z Indexed on 2010/03/20 22:31 UTC
Read the original article Hit count: 243

Filed under:
|
|

I'm currently working on a web app written in Symfony. I'm supposed to add an "export to CSV" feature in the backend/administration part of the app for some modules. In the list view, there should be an "Export" button which should provide the user with a csv file of the elements that are displayed (considering filtering criteria).

I've created a method in the actions class of the module that takes a comma separated list of ids and generates the CSV, but I'm not really sure how to add the link to it in the view. The problem is that the view doesn't exist anywhere, it's generated on the fly from the data in the generator.yml configuration file. I've posted the relevant part of the file below.

I'm new to Symfony, so any help would be appreciated :).

Thanks,
Alex

Update


list:
  display: [id, =name, indemn, _status, _participants, _approved_, created_at]
  title: Lista actiuni
  object_actions:
    _edit: ~
    _delete: ~
  actions:
    _create: ~
    export_csv:
      name: Export to CSV
      action: CSVExport
      params: id=csvActionSubmit
  filters: [name, county_id, _status_filter, activity_id]
  fields:
    id:
      name: Nr. crt.
  ...

Thanks to your advice, I've managed to add a button that is linked to my action. The problem is that I also need to send some parameters to the action, because I may not want all the elements - filters may have been used. Unfortunately, the project is using Symfony 1.0, which doesn't support batch_actions.

Currently, I'm working around this with Javascript (I parse the DOM to get the numeric ids (from the display table) and then build the link for the button. I really think there could be a better way for this.

© Stack Overflow or respective owner

Related posts about php

Related posts about symfony