Skip to content

Bug: Can't use multiple pagers on the same view #6204

Closed
@jozefrebjak

Description

@jozefrebjak

PHP Version

8.0

CodeIgniter4 Version

4.1.2

CodeIgniter4 Installation Method

Composer (as dependency to an existing project)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

MariaDB 10.6.5

What happened?

Can't use multiple pagers on the same view. I followed docs from here.

Steps to Reproduce

Here is my simplified Controller function:

public function view(int $clientId)
{
      $contacts = $this->getContactProvider();
      $orders   = $this->getOrderProvider();
      
      return view($this->viewPrefix . 'view', [
                  'title'      => lang('Client.client'),
                  'contacts'   => $contacts->whereClient($clientId)->paginate(preference('Pager.perPage'), 'contacts'),
                  'orders'     => $orders->whereClient($clientId)->paginate(preference('Pager.perPage'), 'orders'),
                  'pager'      => $contacts->whereClient($clientId)->pager,
              ]);
}

Expected Output

Get two groups in Pager instance and show pagers in view with

<?= $pager->simpleLinks('contacts') ?>
<?= $pager->links('orders') ?>

but there is only one group
CleanShot 2022-06-29 at 15 34 27@2x

Anything else?

Within view I can show two paginations, but can access only that one where I'm calling pager method.
CleanShot 2022-06-29 at 15 41 25@2x

But when I manually specify page_contacts like:

?page_contacts=2&page_orders=1

It will show previous page in pagination

CleanShot 2022-06-29 at 15 44 38@2x

I'm expecting both paginations the same, because there is two pages for both of results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions