Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[TwigBridge] Fix Bootstrap 4 form error layout #52373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 5.4
Choose a base branch
from

Conversation

asispts
Copy link
Contributor

@asispts asispts commented Oct 31, 2023

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #52352
License MIT

This PR will fix Bootstrap 4 form layout when using a required marker.

@carsonbot
Copy link

It looks like you unchecked the "Allow edits from maintainer" box. That is fine, but please note that if you have multiple commits, you'll need to squash your commits into one before this can be merged. Or, you can check the "Allow edits from maintainers" box and the maintainer can squash for you.

Cheers!

Carsonbot

@asispts
Copy link
Contributor Author

asispts commented Oct 31, 2023

Here is the result.

@carsonbot carsonbot changed the title Fix bootstrap 4 form error layout [Form] Fix bootstrap 4 form error layout Oct 31, 2023
@carsonbot carsonbot changed the title [Form] Fix bootstrap 4 form error layout [TwigBridge] Fix bootstrap 4 form error layout Oct 31, 2023
@asispts
Copy link
Contributor Author

asispts commented Nov 2, 2023

I think this failure is related.

1) Symfony\Bridge\Twig\Tests\Node\FormThemeTest::testCompile
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'$this->env->getRuntime("Symfony\\Component\\Form\\FormRenderer")->setTheme(($context["form"] ?? null), [0 => "tpl1", 1 => "tpl2"], true);'
+'$this->env->getRuntime("Symfony\\Component\\Form\\FormRenderer")->setTheme(($context["form"] ?? null), ["tpl1", "tpl2"], true);'

/home/runner/work/symfony/symfony/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php:63

Any idea how to fix the test?

$this->assertEquals(
sprintf(
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [1 => "tpl1", 0 => "tpl2"], true);',
$this->getVariableGetter('form')
),
trim($compiler->compile($node)->getSource())
);
$node = new FormThemeNode($form, $resources, 0, null, true);
$this->assertEquals(
sprintf(
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [1 => "tpl1", 0 => "tpl2"], false);',
$this->getVariableGetter('form')
),
trim($compiler->compile($node)->getSource())
);

@OskarStark OskarStark changed the title [TwigBridge] Fix bootstrap 4 form error layout [TwigBridge] Fix Bootstrap 4 form error layout Nov 3, 2023
@asispts asispts force-pushed the fix/bootstrap-4-form-layout branch 2 times, most recently from c91e565 to d9d92e6 Compare November 12, 2023 19:16
@asispts
Copy link
Contributor Author

asispts commented Nov 15, 2023

This failed test doesn't use the recent change. The line in FormThemeTest.php:63 is a comment, and clearly, there's no [0 => "tpl1", 1 => "tpl2"] in the test code.

I can reproduce the failure in Symfony 4 and PHP 8.2 + high-deps. The result of (new Compiler($environment))->subcompile($node->getNode('resources'))->getSource()) is indeed ["tpl1", "tpl2"]. While in the recent version of Symfony, the result is [1 => "tpl1", 0 => "tpl2"]

1) Symfony\Bridge\Twig\Tests\Node\FormThemeTest::testCompile
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'$this->env->getRuntime("Symfony\\Component\\Form\\FormRenderer")->setTheme(($context["form"] ?? null), [0 => "tpl1", 1 => "tpl2"], true);'
+'$this->env->getRuntime("Symfony\\Component\\Form\\FormRenderer")->setTheme(($context["form"] ?? null), ["tpl1", "tpl2"], true);'

/home/runner/work/symfony/symfony/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php:63

@fabpot fabpot modified the milestones: 5.4, 6.4 Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants