$form->onSuccess[] function not executed in Nette 2.2.6
Notice: This thread is very old.
- OKweb
- Member | 12
I updated from Nette 2.2.3 to 2.2.6 and it looks like the function I set in $form->onSuccess[] is not executed, only link from $form->setAction() is opened.
This worked in Nette 2.2.3:
<?php
protected function createComponentProduktForm()
{
$form = new Nette\Application\UI\Form;
$polozky = array();
foreach ($this->database->table('avg_katalog') as $polozka)
$polozky[$polozka->id] = $polozka->id;
$form->addRadioList('polozka', 'Položka:', $polozky)->setRequired('Vyberte, prosím, položku, ktorú chcete pridať do košíka.');
$form->addSubmit('pridat', 'Pridať do košíka');
$form->setAction($this->link('Product:default', array('slug' => $this->getParameter('slug'))));
$form->onSuccess[] = $this->produktFormSucceeded;
return $form;
}
public function produktFormSucceeded($form)
{
$values = $form->getValues();
$polozka = $values->polozka;
$nakupnyKosik = $this->getSession('nakupnyKosik');
if (isset($nakupnyKosik->polozky[$polozka]))
$nakupnyKosik->polozky[$polozka]++;
else
$nakupnyKosik->polozky[$polozka] = 1;
}
?>
- Casper
- Member | 253
It is caused by this commit, see related threads and original issue.
Ugly solution should be:
$form->setAction($this->link('Product:default', array(
'slug' => $this->getParameter('slug'),
'do' => 'produktForm-submit' // or use $name passed to createComponent* method instead of produktForm
)));
Last edited by Casper (2014-11-19 15:41)
- OKweb
- Member | 12
Casper wrote:
It is caused by this commit, see related threads and original issue.
Ugly solution should be:
$form->setAction($this->link('Product:default', array( 'slug' => $this->getParameter('slug'), 'do' => 'produktForm-submit' // or use $name passed to createComponent* method instead of produktForm )));
Thanks! It is helpful.