silverstripe / silverstripe-reports

API for creating backend reports in the Silverstripe Framework.
BSD 3-Clause "New" or "Revised" License
6 stars 29 forks source link

FIX broken URL builder when using MultiSelectFields as parameters #169

Closed wilr closed 1 year ago

wilr commented 1 year ago

When using MultiSelectField instances (or any field name that has the [] syntax - I also tested with TagField to confirm it was broken) the current implementation only pushes the final value into the URL rather than all instances of them.

Repo example if you want to test pre / post. You'll note on current 4 only 1 value of ListboxField is saved.

<?php

use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\ListboxField;
use SilverStripe\Reports\Report;

class TestReport extends Report
{
    public function title()
    {
        return 'Report';
    }

    public function parameterFields()
    {
        return FieldList::create([
            ListboxField::create('PageID', 'Page', Page::get())
        ]);
    }

    public function sourceRecords($params = [], $sort = null, $limit = null)
    {
        $pages = Page::get();

        if (isset($params['PageID'])) {
            $pages = $pages->filter('ID', $params['PageID']);
        }

        return $pages;
    }
}
GuySartorelli commented 1 year ago

Please target the 4.13 branch so that this can be released as a patch fix. We aren't releasing any new minor releases for the CMS 4 compatible branches.

wilr commented 1 year ago

@GuySartorelli Retarged now.