Skip to content

Commit

Permalink
impl. proper fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jun 19, 2023
1 parent 3d08d09 commit 688774e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ItemsPerPageSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Atk4\Ui;

use Atk4\Data\Field;
use Atk4\Ui\Js\JsExpression;

/**
Expand Down Expand Up @@ -32,6 +33,11 @@ class ItemsPerPageSelector extends View
/** @var Callback|null The callback function. */
public $cb;

private function formatInteger(int $value): string
{
return $this->getApp()->uiPersistence->typecastSaveField(new Field(['type' => 'integer']), $value);
}

protected function init(): void
{
parent::init();
Expand All @@ -45,7 +51,7 @@ protected function init(): void
if (!$this->currentIpp) {
$this->currentIpp = $this->pageLengthItems[0];
}
$this->set((string) $this->currentIpp);
$this->set($this->formatInteger($this->currentIpp));
}

/**
Expand All @@ -60,7 +66,7 @@ public function onPageLengthSelect(\Closure $fx): void
$this->cb->set(function () use ($fx) {
$ipp = isset($_GET['ipp']) ? (int) $_GET['ipp'] : null;
// $this->pageLength->set(preg_replace("/\[ipp\]/", $ipp, $this->label));
$this->set((string) $ipp);
$this->set($this->formatInteger($ipp));
$reload = $fx($ipp);
if ($reload) {
$this->getApp()->terminateJson($reload);
Expand Down

0 comments on commit 688774e

Please sign in to comment.