Skip to content

Bug: [Pager] Knocks down variables for View #7703

@neznaika0

Description

@neznaika0

PHP Version

8.2

CodeIgniter4 Version

4.3.6

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

cli-server (PHP built-in webserver)

Database

No response

What happened?

I couldn't determine exactly why it works in one place and not in another. When calling $pager->links(), my parameters set inside the template disappear. I added a "title", but it disappears after the Pager. If you install it in the controller, everything is fine. BUT elsewhere, setting variables in the template works fine (even with Pager)

Steps to Reproduce

<?php
// init $model->paginate() in Controller
$this->setVar('title', 'New title');

echo $this->extend('_layout/backend');
?>

<?= $this->section('content') ?>
    <table class="table text-center">
        ...
    </table>
    <?php dd($this, 'first') ?>

    <?= $pager->links('default'); ?>

    <?php dd($this, 'second') ?>
<?= $this->endSection() ?>

In first dump N variables, in second N-1 vars (unset "title")

Expected Output

I looked into the system Pager file. It calls $this->view->setVar('pager', $pager)->render(...) Probably this call interrupts the previous template code?

Anything else?

No response

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