Using a form from a different presenter

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.

Read the rest of this entry »

Returning from a template

July 25th, 2011

Ever needed to return from a template earlier than at its end? Exit in the middle or even at the very beginning because you don’t want to print the rest of the template?
Read the rest of this entry »

Fake function/method overloading in PHP

June 26th, 2011

Ever needed to call the same function with different number of parameters? Easy right, just use default values:

  1.  

But what if you want to make the first parameter optional?
Here’s a simple technique for doing so it in a transparent way.
Read the rest of this entry »

Presenter lifecycle after form is submitted

June 19th, 2011

Nette documentation doesn’t provide details about methods execution order in case of a submitted form. So hear hear, it is this:

  1. action<Action>
  2. createComponent<FormName>
  3. <FormName>Submitted
  4. render<Action>

Read the rest of this entry »

Missing layout? Make sure you define block for content

June 16th, 2011

I’ve had some troubles with a page that refused to be wrapped in a layout. It turned out I accidentally erased {block #content} in my presenter template. Read on for the background logic explanation.
Read the rest of this entry »