Skip to content

Instantly share code, notes, and snippets.

@Majkl578
Created June 12, 2010 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Majkl578/435264 to your computer and use it in GitHub Desktop.
Save Majkl578/435264 to your computer and use it in GitHub Desktop.
<?php
use Nette\Application\AppForm;
class TestPresenter extends Nette\Application\Presenter
{
public function renderDefault()
{
$this['test']->render();
}
protected function createComponentTest()
{
$form = new AppForm($this, 'test');
$form->addText('txt', 'text')
->addRule(AppForm::INTEGER, 'Not a number')
->addRule(function ($control) {
return strlen($control->value) > 3;
}, 'Not long enough');
$form->addSubmit('s', 'send');
$form->onSubmit[] = function ($frm) {
dump($frm->values);
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment