silverstripe / silverstripe-reports

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

broken URL builder when using MultiSelectFields as parameters #170

Closed GuySartorelli closed 11 months ago

GuySartorelli commented 12 months ago

Reported by @wilr:

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;
    }
}

PRs

GuySartorelli commented 11 months ago

PR was merged. This will be tagged automatically by GitHub actions (if it hasn't been already)