Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum persistent changed to array #1558

Open
Leinad90 opened this issue Apr 25, 2023 · 0 comments
Open

Enum persistent changed to array #1558

Leinad90 opened this issue Apr 25, 2023 · 0 comments

Comments

@Leinad90
Copy link

Peesenter

 final class HomepagePresenter extends Nette\Application\UI\Presenter
{

    #[Persistent]
    public int $page=1;

    #[Persistent]
    public int $items=10;

    #[Persistent]
    public OrderBy $orderBy = OrderBy::ASC;


    public function renderDefault() : void
    {

        $count = $this->brand->getCount();
        $paginator = new Nette\Utils\Paginator;
        $paginator->setItemCount($count);
        $paginator->setItemsPerPage($this->items);
        $paginator->setPage($this->page);

        $brands = $this->brand->getPage($paginator->getOffset(), $paginator->getLength(),$this->orderBy);

        $this->template->brands = $brands;
        $this->template->paginator = $paginator;

    }
}

Template

    {dump  $brands}
					<a href="{link default orderBy: orderBy::DESC}" class="ajax btn ">DESC</a>
					<a href="{link default orderBy: orderBy::ASC}" class="ajax btn ">ASC</a>
	<div class="right-align">
		<ul class="pagination">Stránka
			{for $i = $paginator->getFirstPage();  $i<= $paginator->getLastPage() ; $i ++ }
			    <li class="waves-effect {if $i===$paginator->getPage()}active{/if}">
					<a href="{link default page: $i}" class="ajax btn ">{$i}</a>
				</li>
			{/for}
		</ul>
		<p>Záznamů na stránku
			{for $j = 10; $j < 31; $j+=10 }
				<span>
					<a href="{link default items: $j}" class="ajax">{$j}</a>
				</span>
			{/for}
		</p>
	</div>

Enum:

<?php

namespace app\Model;
enum OrderBy: string
{
    case DESC = 'DESC';
    case ASC = 'ASC';

}

When clicking on this page(load same action in same presenter) got error
Value passed to persistent parameter 'orderBy' in presenter Homepage must be [app\Model\OrderBy].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant