diff --git a/composer.json b/composer.json
index 3b0d626fc..873278898 100644
--- a/composer.json
+++ b/composer.json
@@ -24,12 +24,12 @@
"nette/application": "^3.0",
"nette/di": "^3.0",
"nette/tester": "^2.5.2",
- "latte/latte": "^2.10.2 || ^3.0.12",
+ "latte/latte": "^3.0.12",
"tracy/tracy": "^2.9",
"phpstan/phpstan-nette": "^2.0@stable"
},
"conflict": {
- "latte/latte": ">=3.0.0 <3.0.12 || >=3.2"
+ "latte/latte": "<3.0.12 || >=3.2"
},
"suggest": {
"ext-intl": "to use date/time controls"
@@ -47,7 +47,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "3.2-dev"
+ "dev-master": "4.0-dev"
}
}
}
diff --git a/readme.md b/readme.md
index 630329eec..45ffe2514 100644
--- a/readme.md
+++ b/readme.md
@@ -2,8 +2,8 @@ Nette Forms: greatly facilitates web forms
==========================================
[](https://packagist.org/packages/nette/forms)
-[](https://github.com/nette/forms/actions)
-[](https://coveralls.io/github/nette/forms?branch=v3.2)
+[](https://github.com/nette/forms/actions)
+[](https://coveralls.io/github/nette/forms?branch=master)
[](https://github.com/nette/forms/releases)
[](https://github.com/nette/forms/blob/master/license.md)
diff --git a/rollup.config.js b/rollup.config.js
index 8a3697543..95ba912a3 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -34,21 +34,21 @@ function spaces2tabs() {
export default [
- {
+ { // TODO: consider the possibility of cutting off the UMD versions completely due to collision
input: 'src/assets/index.umd.ts',
output: [
{
format: 'umd',
name: 'Nette',
- dir: 'src/assets',
- entryFileNames: 'netteForms.js',
+ dir: 'src/assets/dist',
+ entryFileNames: 'nette-forms.umd.js',
generatedCode: 'es2015',
},
{
format: 'umd',
name: 'Nette',
- dir: 'src/assets',
- entryFileNames: 'netteForms.min.js',
+ dir: 'src/assets/dist',
+ entryFileNames: 'nette-forms.umd.min.js',
generatedCode: 'es2015',
plugins: [
terser(),
@@ -65,9 +65,36 @@ export default [
},
{
- input: 'src/assets/index.umd.ts',
+ input: 'src/assets/index.esm.ts',
+ output: [
+ {
+ format: 'es',
+ dir: 'src/assets/dist',
+ entryFileNames: 'nette-forms.esm.js',
+ generatedCode: 'es2015',
+ },
+ {
+ format: 'es',
+ dir: 'src/assets/dist',
+ entryFileNames: 'nette-forms.esm.min.js',
+ generatedCode: 'es2015',
+ plugins: [
+ terser(),
+ ],
+ },
+ ],
+ plugins: [
+ json(),
+ nodeResolve(),
+ typescript(),
+ spaces2tabs(),
+ ],
+ },
+
+ {
+ input: 'src/assets/index.esm.ts',
output: [{
- file: 'src/assets/netteForms.d.ts',
+ file: 'src/assets/dist/nette-forms.d.ts',
format: 'es',
}],
plugins: [
diff --git a/src/Bridges/FormsLatte/FormMacros.php b/src/Bridges/FormsLatte/FormMacros.php
deleted file mode 100644
index 18c889ad2..000000000
--- a/src/Bridges/FormsLatte/FormMacros.php
+++ /dev/null
@@ -1,330 +0,0 @@
-addMacro('form', [$me, 'macroForm'], 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));');
- $me->addMacro('formContext', [$me, 'macroFormContext'], 'array_pop($this->global->formsStack);');
- $me->addMacro('formContainer', [$me, 'macroFormContainer'], 'array_pop($this->global->formsStack); $formContainer = end($this->global->formsStack)');
- $me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], null, self::AUTO_EMPTY);
- $me->addMacro('input', [$me, 'macroInput']);
- $me->addMacro('name', [$me, 'macroName'], [$me, 'macroNameEnd'], [$me, 'macroNameAttr']);
- $me->addMacro('inputError', [$me, 'macroInputError']);
- $me->addMacro('formPrint', [$me, 'macroFormPrint']);
- $me->addMacro('formClassPrint', [$me, 'macroFormPrint']);
- }
-
-
- /********************* macros ****************d*g**/
-
-
- /**
- * {form ...}
- */
- public function macroForm(MacroNode $node, PhpWriter $writer)
- {
- if ($node->modifiers) {
- throw new CompileException('Modifiers are not allowed in ' . $node->getNotation());
- }
-
- if ($node->prefix) {
- throw new CompileException('Did you mean
@@ -89,17 +89,17 @@
@@ -111,9 +111,3 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/Forms.Latte3/expected/forms.php b/tests/Forms.Latte3/expected/forms.php
index 55e8d7350..10fa0b901 100644
--- a/tests/Forms.Latte3/expected/forms.php
+++ b/tests/Forms.Latte3/expected/forms.php
@@ -1,97 +1,96 @@
global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */;
- Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
- echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, ['id' => 'myForm', 'class' => 'ajax']) /* line %d% */;
+ $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */;
+ echo $this->global->forms->renderFormBegin(['id' => 'myForm', 'class' => 'ajax']) /* line %d% */;
echo "\n";
foreach (['id', 'username', 'select', 'area', 'send'] as $name) /* line %d% */ {
echo ' ';
- echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item($name, $this->global)->getLabel()) /* line %d% */;
+ echo ($ʟ_label = $this->global->forms->item($name)->getLabel()) /* line %d% */;
echo '
';
- echo Nette\Bridges\FormsLatte\Runtime::item($name, $this->global)->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */;
+ echo $this->global->forms->item($name)->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */;
echo '
';
- echo LR\%a%::escape%a%(Nette\Bridges\FormsLatte\Runtime::item($name, $this->global)->getError()) /* line %d% */;
+ echo LR\Filters::escapeHtmlText($this->global->forms->item($name)->getError()) /* line %d% */;
echo '
';
- echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item($form[$name], $this->global)->getLabel())?->addAttributes(['title' => 'hello'])?->startTag() /* line %d% */;
+ echo ($ʟ_label = $this->global->forms->item($form[$name])->getLabel())?->addAttributes(['title' => 'hello'])?->startTag() /* line %d% */;
echo ' ';
- echo Nette\Bridges\FormsLatte\Runtime::item($form[$name], $this->global)->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */;
+ echo $this->global->forms->item($form[$name])->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */;
echo ' ';
echo $ʟ_label?->endTag() /* line %d% */;
echo '
';
- echo LR\%a%::escape%a%(Nette\Bridges\FormsLatte\Runtime::item($form[$name], $this->global)->getError()) /* line %d% */;
+ echo LR\Filters::escapeHtmlText($this->global->forms->item($form[$name])->getError()) /* line %d% */;
echo "\n";
}
echo '
';
- echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item($form['username'], $this->global)->getLabel()) /* line %d% */;
+ echo ($ʟ_label = $this->global->forms->item($form['username'])->getLabel()) /* line %d% */;
echo '
global)->getControlPart())->addAttributes(['value' => null, 'type' => null, 'class' => null])->attributes() /* line %d% */;
+ echo ($ʟ_elem = $this->global->forms->item('username')->getControlPart())->addAttributes(['value' => null, 'type' => null, 'class' => null])->attributes() /* line %d% */;
echo '>
global)->getControlPart())->attributes() /* line %d% */;
+ echo ($ʟ_elem = $this->global->forms->item($form['username'])->getControlPart())->attributes() /* line %d% */;
echo '>
';
- echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('my', $this->global)->getLabel()) /* line %d% */;
- echo Nette\Bridges\FormsLatte\Runtime::item('my', $this->global)->getControl() /* line %d% */;
+ echo ($ʟ_label = $this->global->forms->item('my')->getLabel()) /* line %d% */;
+ echo $this->global->forms->item('my')->getControl() /* line %d% */;
echo "\n";
- echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */;
+ echo $this->global->forms->renderFormEnd() /* line %d% */;
+ $this->global->forms->end();
echo '
';
- $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */;
- Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
- echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */;
- echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */;
+ $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */;
+ echo $this->global->forms->renderFormBegin([]) /* line %d% */;
+ echo $this->global->forms->renderFormEnd() /* line %d% */;
+ $this->global->forms->end();
echo '
';
- $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */;
- Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
- echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */;
+ $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */;
+ echo $this->global->forms->renderFormBegin([]) /* line %d% */;
echo "\n";
foreach ($form['sex']->items as $key => $label) /* line %d% */ {
echo ' ';
- echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('sex', $this->global)->getLabelPart($key))?->startTag() /* line %d% */;
+ echo ($ʟ_label = $this->global->forms->item('sex')->getLabelPart($key))?->startTag() /* line %d% */;
echo ' ';
- echo Nette\Bridges\FormsLatte\Runtime::item('sex', $this->global)->getControlPart($key) /* line %d% */;
+ echo $this->global->forms->item('sex')->getControlPart($key) /* line %d% */;
echo ' ';
echo LR\%a%::escape%a%($label) /* line %d% */;
echo $ʟ_label?->endTag() /* line %d% */;
echo '
@@ -100,47 +99,47 @@
}
echo '
global)->getControlPart("{$key}"))->attributes() /* line %d% */;
+ echo ($ʟ_elem = $this->global->forms->item($form['sex'])->getControlPart("{$key}"))->attributes() /* line %d% */;
echo '>
';
- echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('checkbox', $this->global)->getLabelPart(''))?->startTag() /* line %d% */;
+ echo ($ʟ_label = $this->global->forms->item('checkbox')->getLabelPart(''))?->startTag() /* line %d% */;
echo ' ';
- echo Nette\Bridges\FormsLatte\Runtime::item('checkbox', $this->global)->getControlPart('') /* line %d% */;
+ echo $this->global->forms->item('checkbox')->getControlPart('') /* line %d% */;
echo ' Label';
echo $ʟ_label?->endTag() /* line %d% */;
echo '
@@ -149,20 +148,20 @@
';
foreach ($form['checklist']->items as $key => $label) /* line %d% */ {
echo ' ';
- echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('checklist', $this->global)->getLabelPart($key))?->startTag() /* line %d% */;
+ echo ($ʟ_label = $this->global->forms->item('checklist')->getLabelPart($key))?->startTag() /* line %d% */;
echo ' ';
- echo Nette\Bridges\FormsLatte\Runtime::item('checklist', $this->global)->getControlPart($key) /* line %d% */;
+ echo $this->global->forms->item('checklist')->getControlPart($key) /* line %d% */;
echo ' ';
echo LR\%a%::escape%a%($label) /* line %d% */;
echo $ʟ_label?->endTag() /* line %d% */;
echo '
@@ -171,15 +170,15 @@
}
echo '
@@ -187,93 +186,73 @@
';
if (1) /* line %d% */ {
- $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */;
- Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
+ $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */;
echo '
';
- array_pop($this->global->formsStack);
+ $this->global->forms->end();
}
echo '
';
- $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */;
- Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
+ $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */;
echo '
';
- array_pop($this->global->formsStack);
+ $this->global->forms->end();
echo '
';
- $form = $this->global->formsStack[] = is_object($ʟ_tmp = $this->global->uiControl['myForm']) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp] /* line %d% */;
- Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
+ $this->global->forms->begin($form = (is_object($ʟ_tmp = $this->global->uiControl['myForm']) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp])) /* line %d% */;
echo '
';
- array_pop($this->global->formsStack);
+ $this->global->forms->end();
echo '
';
- echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */;
-
- echo '
-
-
-';
- $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */;
- Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
- echo '
-
-global)->getControlPart())->attributes() /* line %d% */;
- echo '>
-';
- array_pop($this->global->formsStack) /* line %d% */;
+ echo $this->global->forms->renderFormEnd() /* line %d% */;
+ $this->global->forms->end();
%A%
diff --git a/tests/Forms.Latte3/forms.button.phpt b/tests/Forms.Latte3/forms.button.phpt
index 136f44bd3..6e8aa59c1 100644
--- a/tests/Forms.Latte3/forms.button.phpt
+++ b/tests/Forms.Latte3/forms.button.phpt
@@ -8,10 +8,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (version_compare(Latte\Engine::VERSION, '3', '<')) {
- Tester\Environment::skip('Test for Latte 3');
-}
-
$form = new Form;
$form->addSubmit('send', 'Sign in');
diff --git a/tests/Forms.Latte3/forms.error.phpt b/tests/Forms.Latte3/forms.error.phpt
index b18a61a4a..f4a9c7dbf 100644
--- a/tests/Forms.Latte3/forms.error.phpt
+++ b/tests/Forms.Latte3/forms.error.phpt
@@ -7,10 +7,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (version_compare(Latte\Engine::VERSION, '3', '<')) {
- Tester\Environment::skip('Test for Latte 3');
-}
-
$latte = new Latte\Engine;
$latte->setLoader(new Latte\Loaders\StringLoader);
diff --git a/tests/Forms.Latte3/forms.formContainer.phpt b/tests/Forms.Latte3/forms.formContainer.phpt
index 51eb27da6..f22b3baae 100644
--- a/tests/Forms.Latte3/forms.formContainer.phpt
+++ b/tests/Forms.Latte3/forms.formContainer.phpt
@@ -8,10 +8,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (version_compare(Latte\Engine::VERSION, '3', '<')) {
- Tester\Environment::skip('Test for Latte 3');
-}
-
$form = new Form;
$form->addText('input1', 'Input 1');
diff --git a/tests/Forms.Latte3/forms.get.phpt b/tests/Forms.Latte3/forms.get.phpt
index e1dada478..a2fa0ffd8 100644
--- a/tests/Forms.Latte3/forms.get.phpt
+++ b/tests/Forms.Latte3/forms.get.phpt
@@ -8,10 +8,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (version_compare(Latte\Engine::VERSION, '3', '<')) {
- Tester\Environment::skip('Test for Latte 3');
-}
-
$form = new Form;
$form->setMethod('get');
diff --git a/tests/Forms.Latte3/forms.phpt b/tests/Forms.Latte3/forms.phpt
index 0cc769add..c7724fac7 100644
--- a/tests/Forms.Latte3/forms.phpt
+++ b/tests/Forms.Latte3/forms.phpt
@@ -8,10 +8,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (version_compare(Latte\Engine::VERSION, '3', '<')) {
- Tester\Environment::skip('Test for Latte 3');
-}
-
class MyControl extends Nette\Forms\Controls\BaseControl
{
diff --git a/tests/Forms.Latte3/n-name.form.phpt b/tests/Forms.Latte3/n-name.form.phpt
index e018bea58..6192700a0 100644
--- a/tests/Forms.Latte3/n-name.form.phpt
+++ b/tests/Forms.Latte3/n-name.form.phpt
@@ -7,10 +7,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (version_compare(Latte\Engine::VERSION, '3', '<')) {
- Tester\Environment::skip('Test for Latte 3');
-}
-
$latte = new Latte\Engine;
$latte->setLoader(new Latte\Loaders\StringLoader);
@@ -19,14 +15,13 @@ $latte->addExtension(new FormsExtension);
Assert::match(
<<<'XX'
%A%
- $form = $this->global->formsStack[] = $this->global->uiControl['foo'] /* line 1 */;
- Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
+ $this->global->forms->begin($form = $this->global->uiControl['foo']) /* line 1 */;
echo '';
- array_pop($this->global->formsStack);
+ $this->global->forms->end();
%A%
XX,
$latte->compile(''),
@@ -36,17 +31,16 @@ Assert::match(
Assert::match(
<<<'XX'
%A%
- $form = $this->global->formsStack[] = $this->global->uiControl['foo'] /* line 1 */;
- Nette\Bridges\FormsLatte\Runtime::initializeForm($form);
+ $this->global->forms->begin($form = $this->global->uiControl['foo']) /* line 1 */;
$ʟ_tag[0] = '';
if (0) /* line 1 */ {
%A%
- echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), [], false) /* line 1 */;
+ echo $this->global->forms->renderFormBegin([], false) /* line 1 */;
echo '>';
}
- echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line 1 */;
+ echo $this->global->forms->renderFormEnd(false) /* line 1 */;
echo $ʟ_tag[0];
- array_pop($this->global->formsStack);
+ $this->global->forms->end();
%A%
XX,
$latte->compile(''),
diff --git a/tests/Forms.Latte3/n-name.input.phpt b/tests/Forms.Latte3/n-name.input.phpt
index 0572ddb36..164845451 100644
--- a/tests/Forms.Latte3/n-name.input.phpt
+++ b/tests/Forms.Latte3/n-name.input.phpt
@@ -7,22 +7,18 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (version_compare(Latte\Engine::VERSION, '3', '<')) {
- Tester\Environment::skip('Test for Latte 3');
-}
-
$latte = new Latte\Engine;
$latte->setLoader(new Latte\Loaders\StringLoader);
$latte->addExtension(new FormsExtension);
Assert::match(
- '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart())->attributes() %A%',
+ '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart())->attributes() %A%',
$latte->compile(''),
);
Assert::match(
- '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\'))->attributes() %A%',
+ '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart(\'\'))->attributes() %A%',
$latte->compile(''),
);
@@ -33,11 +29,11 @@ Assert::exception(
);
Assert::match(
- '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\'))->attributes() %A%',
+ '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart(\'x\'))->attributes() %A%',
$latte->compile(''),
);
Assert::match(
- '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\'))->attributes() %A%',
+ '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart(\'x\'))->attributes() %A%',
$latte->compile(''),
);
diff --git a/tests/Forms.Latte3/templates/forms.latte b/tests/Forms.Latte3/templates/forms.latte
index 7196558bc..91153dcfd 100644
--- a/tests/Forms.Latte3/templates/forms.latte
+++ b/tests/Forms.Latte3/templates/forms.latte
@@ -80,9 +80,3 @@
{/form}
-
-
-{formContext myForm}
-
-
-{/formContext myForm}
diff --git a/tests/Forms.Latte3/{input}.phpt b/tests/Forms.Latte3/{input}.phpt
index 798c091ce..02b236220 100644
--- a/tests/Forms.Latte3/{input}.phpt
+++ b/tests/Forms.Latte3/{input}.phpt
@@ -7,32 +7,28 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (version_compare(Latte\Engine::VERSION, '3', '<')) {
- Tester\Environment::skip('Test for Latte 3');
-}
-
$latte = new Latte\Engine;
$latte->setLoader(new Latte\Loaders\StringLoader);
$latte->addExtension(new FormsExtension);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControl() %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControl() %A%',
$latte->compile('{input foo}'),
);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControl()->addAttributes([\'class\' => \'foo\']) %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControl()->addAttributes([\'class\' => \'foo\']) %A%',
$latte->compile('{input foo class => foo}'),
);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControl()->addAttributes([\'class\' => \'foo\']) %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControl()->addAttributes([\'class\' => \'foo\']) %A%',
$latte->compile('{input foo, class => foo}'),
);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\') %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\') %A%',
$latte->compile('{input foo:}'),
);
@@ -43,31 +39,31 @@ Assert::exception(
);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\') %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\') %A%',
$latte->compile('{input foo:,}'),
);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\')->addAttributes([\'class\' => \'foo\']) %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\')->addAttributes([\'class\' => \'foo\']) %A%',
$latte->compile('{input foo:, class => foo}'),
);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\') %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%',
$latte->compile('{input foo:x}'),
);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\')->addAttributes([\'class\' => \'foo\']) %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\')->addAttributes([\'class\' => \'foo\']) %A%',
$latte->compile('{input foo:x, class => foo}'),
);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\') %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%',
$latte->compile('{input "foo":"x"}'),
);
Assert::match(
- '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\') %A%',
+ '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%',
$latte->compile('{input "foo" : "x"}'),
);
diff --git a/tests/Forms.Latte3/{label}.phpt b/tests/Forms.Latte3/{label}.phpt
index a581a3eb3..b09ceca04 100644
--- a/tests/Forms.Latte3/{label}.phpt
+++ b/tests/Forms.Latte3/{label}.phpt
@@ -7,32 +7,28 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (version_compare(Latte\Engine::VERSION, '3', '<')) {
- Tester\Environment::skip('Test for Latte 3');
-}
-
$latte = new Latte\Engine;
$latte->setLoader(new Latte\Loaders\StringLoader);
$latte->addExtension(new FormsExtension);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabel()) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel()) %A%',
$latte->compile('{label foo /}'),
);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%',
$latte->compile('{label foo class => foo /}'),
);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%',
$latte->compile('{label foo, class => foo /}'),
);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'\')) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\')) %A%',
$latte->compile('{label foo: /}'),
);
@@ -43,31 +39,31 @@ Assert::exception(
);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'\')) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\')) %A%',
$latte->compile('{label foo:, /}'),
);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'\'))?->addAttributes([\'class\' => \'foo\']) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\'))?->addAttributes([\'class\' => \'foo\']) %A%',
$latte->compile('{label foo:, class => foo /}'),
);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\')) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%',
$latte->compile('{label foo:x /}'),
);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\'))?->addAttributes([\'class\' => \'foo\']) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\'))?->addAttributes([\'class\' => \'foo\']) %A%',
$latte->compile('{label foo:x, class => foo /}'),
);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\')) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%',
$latte->compile('{label "foo":"x" /}'),
);
Assert::match(
- '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\')) %A%',
+ '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%',
$latte->compile('{label "foo" : "x" /}'),
);
diff --git a/tests/Forms/Container.getControls().phpt b/tests/Forms/Container.getControls().phpt
index 5c4d2bef0..3c605a6ef 100644
--- a/tests/Forms/Container.getControls().phpt
+++ b/tests/Forms/Container.getControls().phpt
@@ -15,22 +15,4 @@ $form->addContainer('cont')
->addText('name');
$controls = $form->getControls();
-
-$names = $values = [];
-foreach ($controls as $name => $value) {
- $names[] = $name;
- $values[] = $value;
-}
-
-Assert::same(['name', 'age', 'name'], $names);
-Assert::same([$form['name'], $form['age'], $form['cont-name']], $values);
-
-// again
-$names = $values = [];
-foreach ($controls as $name => $value) {
- $names[] = $name;
- $values[] = $value;
-}
-
-Assert::same(['name', 'age', 'name'], $names);
-Assert::same([$form['name'], $form['age'], $form['cont-name']], $values);
+Assert::same([$form['name'], $form['age'], $form['cont-name']], $controls);
diff --git a/tests/Forms/Container.values.mapping.phpt b/tests/Forms/Container.values.mapping.phpt
index 043d6cbc7..4e27d1797 100644
--- a/tests/Forms/Container.values.mapping.phpt
+++ b/tests/Forms/Container.values.mapping.phpt
@@ -11,15 +11,14 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-#[AllowDynamicProperties]
-class FormData
+class FormData extends stdClass
{
public string $title;
public FormFirstLevel $first;
}
-class FormFirstLevel
+class FormFirstLevel extends stdClass
{
public string $name;
public ?int $age = null;
@@ -27,7 +26,7 @@ class FormFirstLevel
}
-class FormSecondLevel
+class FormSecondLevel extends stdClass
{
public string $city;
}
diff --git a/tests/Forms/expected/Forms.renderer.1.expect b/tests/Forms/expected/Forms.renderer.1.expect
index 4f6276143..3c17482dd 100644
--- a/tests/Forms/expected/Forms.renderer.1.expect
+++ b/tests/Forms/expected/Forms.renderer.1.expect
@@ -14,7 +14,7 @@
|
-
+ |
Enter your age |
@@ -54,14 +54,14 @@
|
-
+ |
Enter your shipping address |
|
-
+ |
Select your country |
@@ -81,7 +81,7 @@
|
-
+ |
Reenter your password |
diff --git a/tests/Forms/expected/Forms.renderer.2.expect b/tests/Forms/expected/Forms.renderer.2.expect
index 4fbec753b..4b4872f59 100644
--- a/tests/Forms/expected/Forms.renderer.2.expect
+++ b/tests/Forms/expected/Forms.renderer.2.expect
@@ -13,14 +13,14 @@
- •
+ •
Age must be numeric value
-
+
Please select a valid option.
@@ -73,7 +73,7 @@
- • (at least 3 characters)
+ • (at least 3 characters)
The password is too short: it must be at least 3 characters
diff --git a/tests/Forms/expected/Forms.renderer.translate.expect b/tests/Forms/expected/Forms.renderer.translate.expect
index e1230b986..125b4ac49 100644
--- a/tests/Forms/expected/Forms.renderer.translate.expect
+++ b/tests/Forms/expected/Forms.renderer.translate.expect
@@ -15,7 +15,7 @@
|
-
+ |
WEAK PASSWORD |
diff --git a/tests/netteForms/karma.conf.ts b/tests/netteForms/karma.conf.ts
index 3712c64dd..059cb3d01 100644
--- a/tests/netteForms/karma.conf.ts
+++ b/tests/netteForms/karma.conf.ts
@@ -4,7 +4,7 @@ module.exports = function (config) {
frameworks: ['jasmine'],
browsers: ['ChromeHeadless'],
files: [
- '../../src/assets/netteForms.js',
+ '../../src/assets/dist/nette-forms.umd.js',
'spec/*Spec.js',
],
autoWatch: false,