How to create checkbox filter on homepage
Notice: This thread is very old.
- kolaloka
- Member | 69
I have a checkbox on my page and if it is checked, show some content. I created a form that sends the result back to the page, however I do not know, how to get to the values. Here is the relevant code:
Presenter:
<?php
protected function createComponentZakazkaWorkTag()
{
$form=new Form;
$form->addCheckbox('workTag','show only my orders');
$form->addSubmit('send', 'vybrat');
$form->onSuccess[] = [$this, 'renderZakazka'];
return $form;
}
?>
Latte:
<?php
{control zakazkaWorkTag}
{php $value = $getValues(workTag);}
{if $value = 'true'}
{php $this->listMyOrders();}
{/if}
?>
The problem is now how to make this work: {php $value = $getValues(workTag);} ?
Can anybody help? Thanks a million.
- kolaloka
- Member | 69
Well, I finally managed to solve it using this thread:
https://forum.nette.org/…a-zpracovani
In case anyone gets into similar situation, here is the solution:
<?php
$filter = $this->getComponent('zakazkaWorkTag')->getValues(TRUE);
$this->template->zakazkaNew = $this->database->table('zakazka')
->order('id DESC')
->where('done', '0')
->where('workTag1',$filter['workTag1']);
?>