XF 2.3 Array to string conversion

QuackieMackie

Active member
I have just added a multi selection box to some filtering.
HTML:
                        <xf:cell width="41%" rowspan="2">
                            <xf:select name="type" value="{$filters.type}" multiple="true">
                                <xf:option value="any">{{ phrase('any') }}</xf:option>
                                <xf:options source="$filterBits.types" />
                            </xf:select>
                        </xf:cell>

When filters are applied, the filter information is sent to the server and passed back again to the controller.
PHP:
        $filters = [
            'start_date' => $this->filter('start_date', 'datetime'),
            'end_date' => $this->filter('end_date', 'datetime'),
            'type' => $this->filter('type', 'array-str'),
            'user_id' => $this->filter('user_id', 'array-str'),
        ];

This then would then be used to filter logs, the first page has no problem, but when I switch to page x it returns an error Array to string conversion.
HTML:
        <xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}"
                link="logs/addon_logs/view&addon_id={$addonId}&start_date={$filters.start_date}&end_date={$filters.end_date}&type={$filters.type}&user_id={$filters.user_id}"
                wrapperclass="block-outer block-outer--after" />

How do I pass the array correctly into the pagenav?



This is the error i'm getting [E_WARNING] Array to string conversion (internal_data/code_cache/templates/l1/s0/admin/sylphian_addon_logs.php:262)

Which is this line of the cached template
PHP:
'link' => 'logs/addon_logs/view&addon_id=' . $__vars['addonId'] . '&start_date=' . $__vars['filters']['start_date'] . '&end_date=' . $__vars['filters']['end_date'] . '&type=' . $__vars['filters']['type'] . '&user_id=' . $__vars['filters']['user_id'],
 
Solution
Completely my fault, I was using the wrong type.
filters are now:
PHP:
'type' => $this->filter('type', 'array'),
'user_id' => $this->filter('user_id', 'array'),

And page nav gets updated to:
HTML:
        <xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}"
                link="logs/addon_logs/view"
                params="{{ {
                    'addon_id': $addonId,
                    'start_date': $filters.start_date,
                    'end_date': $filters.end_date,
                    'type': $filters.type,
                    'user_id': $filters.user_id
                } }}"
                wrapperclass="block-outer block-outer--after" />
Completely my fault, I was using the wrong type.
filters are now:
PHP:
'type' => $this->filter('type', 'array'),
'user_id' => $this->filter('user_id', 'array'),

And page nav gets updated to:
HTML:
        <xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}"
                link="logs/addon_logs/view"
                params="{{ {
                    'addon_id': $addonId,
                    'start_date': $filters.start_date,
                    'end_date': $filters.end_date,
                    'type': $filters.type,
                    'user_id': $filters.user_id
                } }}"
                wrapperclass="block-outer block-outer--after" />
 
Solution
Back
Top Bottom