form handle method registration
Notice: This thread is very old.
- kapcus
- Member | 3
Hi,
with respect of future Nette and PHP development, what is the preferred way how to register handle method on form ?
<?php
$this->addSubmit('b_save', 'Save')->onSuccess[] = array($this, 'testFormSucceeded')
?>
or
<?php
$this->addSubmit('b_save', 'Save')->onSuccess[] = $this->testFormSucceeded
?>
Thx
- CZechBoY
- Member | 3608
Or via anonymous function, which calls private handle method.
public function create ()
{
$form->onSuccess[] = function (Form $form, ArrayHash $values) {
$this->processForm($form, $values);
};
}
private function processForm (Form $form, ArrayHash $values)
{
// process
}
- David Matějka
- Moderator | 6445
@CZechBoY I also use this very often. Great advantage is that static analysis (references, refactoring…) works well