Archive for August, 2011

Submitting your form to another presenter

Wednesday, August 31st, 2011

You probably know that you can define your form as a component in a class of its own and handle its submission in the same class. This is handy if the submission handling logic can be isolated and is independent of any presenter. But what if it needs to be a part of some particular presenter lifecycle? Then you need to force the form to submit to this particular presenter.
(more…)

Workaround for broken macro {form}

Wednesday, August 31st, 2011

If you ever tried changing your form from POST to GET with $form->setMethod(‘get’) and then render it with macro {form} … {/form} I’m sure you discovered that your submission callback doesn’t trigger. Apparently it’s difficult to resolve this in a clean way so until the Nette team finds a solution you’ll have use some sort of a hacky workaround.

(more…)

Using a form from a different presenter

Sunday, August 28th, 2011

Say you have a search form on a page that lists customers but you also want the same form on the main dashboard page. You have two options: either define your form in a third place and use that definition in both createComponent… methods, or you can create it with createComponent… in BasePresenter and inherit it by both the CustomerPresenter and the DashboardPresenter. Or you can use a hack.

(more…)