|
4 | 4 | * Test: Nette\Forms validation scope. |
5 | 5 | */ |
6 | 6 |
|
7 | | -use Nette\Forms\Form; |
8 | | -use Tester\Assert; |
| 7 | +use Nette\Forms\Container, |
| 8 | + Nette\Forms\Form, |
| 9 | + Tester\Assert; |
9 | 10 |
|
10 | 11 |
|
11 | 12 | require __DIR__ . '/../bootstrap.php'; |
12 | 13 |
|
13 | 14 |
|
14 | 15 | $datasets = [ |
15 | | - ['send1', ['name', 'age', 'age2']], |
16 | | - ['send2', []], |
17 | | - ['send3', ['name']], |
18 | | - ['send4', ['age']], |
19 | | - ['send5', ['age', 'age2']], |
| 16 | + ['send1', ['container', 'form', 'name', 'age', 'age2']], |
| 17 | + ['send2', ['form']], |
| 18 | + ['send3', ['form', 'name']], |
| 19 | + ['send4', ['form', 'age']], |
| 20 | + ['send5', ['container', 'form', 'age', 'age2']], |
20 | 21 | ]; |
21 | 22 |
|
22 | 23 | foreach ($datasets as $case) { |
23 | 24 |
|
24 | 25 | $form = new Form; |
| 26 | + $form->onValidate[] = function (Form $form) { |
| 27 | + $form->addError('form'); |
| 28 | + }; |
25 | 29 | $form->addText('name')->setRequired('name'); |
26 | 30 |
|
27 | 31 | $details = $form->addContainer('details'); |
| 32 | + $details->onValidate[] = function (Container $container) { |
| 33 | + $container->getForm()->addError('container'); |
| 34 | + }; |
28 | 35 | $details->addText('age')->setRequired('age'); |
29 | 36 | $details->addText('age2')->setRequired('age2'); |
30 | 37 |
|
|
0 commit comments