Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » TableListField custom CSV not working?

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1354 Views
  • Sparrowhawk
    Community Member
    33 Posts

    TableListField custom CSV not working? Link to this post


    I have amended the CMS form for one of my pages to include a TableListField.

    This works fine, it shows the 4 columns I have asked it to show for the records in table ProgrammeLaunch.

    However, it is ignoring my custom query that is set for the CSV export (ie on the form I show just 4 fields, but in the CSV export I want to see more fields, but only the 4 fields listed for the form view are being exported. Here is the code:

    class ProgrammeLaunchPage extends Page
    static $db = array();

    function getCMSFields() {
    $fields = parent::getCMSFields();

    return $fields;

    * Returns the questionnaire answers as a TableListField
    * @return TableListField
    protected function getProgrammeLaunchAnswersAsTLF() {

    // Fields to display at the top level
    $fieldList = array(
    'AttendeeName' => 'Name',
    'AttendeeJobTitle' => 'Job Title',
    'AttendeeCompany' => 'Company',
    'LastEdited' => 'Submitted',

    $tf = new TableListField('Responses', 'ProgrammeLaunch', $fieldList);

    $tf->setFieldCasting(array('LastEdited' => 'Date->Nice'));

    // what is user allowed to do?
    $tf->setPermissions(array('show', 'export', 'delete', 'print')); // export permission allows CSV exporting

    //Page navigation

    // CSV output def
    $customCsvQuery = new SQLQuery('*', 'ProgrammeLaunch', null, 'AttendeeName');


    return $tf;


    If I uncomment the die statement, the SQL produced is valid: SELECT * FROM ProgrammeLaunch ORDER BY AttendeeName

    What am I missing?

    Many thanks for any help

  • Sparrowhawk
    Community Member
    33 Posts

    Re: TableListField custom CSV not working? Link to this post

    I've found a solution, although it does not provide an explanation for the above, so if anyone can explain why the above does not work, I'd be very grateful.

    Solution is to use $tf->setFieldListCsv($csvFieldList); instead, where $csvFieldList is an array of field names => field descriptions

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.