Posts Tagged ‘Nette Framework 2.0-beta (revision f38d86f released on 2011-08-24)’

Tweaking your forms

Friday, September 9th, 2011

Nette forms documentation lacks information about enhancing your forms while still using the default renderer. I offer here a list of solutions for the most common needs, using getControlPrototype(), getLabelPrototype(), getSeparatorPrototype() and setOption().
(more…)

IS NOT NULL trouble in Nette/Database

Monday, September 5th, 2011

Sooner or later, you’ll find yourself in a need of filtering out NULL values along with some other criterion. You’ve tried ->where(array('something' => $value, 'other_thing IS NOT NULL')) and got an error. I’m sure you’ve spent considerable time looking for some kind of negation that would work with NULL and I bet you’ve even tried to stick NSqlLiteral somewhere in there. I’m here to rescue you.

(more…)

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…)