Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow passing null in twig_is_selected_choice#46704

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:6.0fromraziel057:patch-11
Jun 17, 2022

Conversation

@raziel057
Copy link
Contributor

@raziel057raziel057 commentedJun 17, 2022
edited
Loading

QA
Branch?6.0 and >
Bug fix?yes
New feature?no
Deprecations?no
LicenseMIT

In the cached file of my application, generated by Symfony I can see the following code fragment:

if (( !((array_key_exists("render_preferred_choices",$context)) ? (_twig_default_filter((isset($context["render_preferred_choices"]) ||array_key_exists("render_preferred_choices",$context) ?$context["render_preferred_choices"] : (function () {thrownewRuntimeError('Variable "render_preferred_choices" does not exist.',88,$this->source); })()),false)) : (false)) &&Symfony\Bridge\Twig\Extension\twig_is_selected_choice($context["choice"], (isset($context["value"]) ||array_key_exists("value",$context) ?$context["value"] : (function () {thrownewRuntimeError('Variable "value" does not exist.',88,$this->source); })())))) {echo" selected=\"selected\"";                }

The 2nd Arg passed when callingtwig_is_selected_choice is the result of(isset($context["value"]) || array_key_exists("value", $context) ? $context["value"]. So in case$context['value'] = null, we passnull as 2nd arg oftwig_is_selected_choice.

As a result in some case, when I submit form with empty (null) value, I got the following error:

Symfony\Bridge\Twig\Extension\twig_is_selected_choice(): Argument #2 ($selectedValue) must be of type array|string, null given, called in ...\var\cache\dev\twig\01\01615438ee40292438687b29025d08a9.php on line 534

Mohammadreza-73 reacted with thumbs up emoji
In the cached file of my application I can see the following code fragment that have been generated by Symfony:```phpif (( !((array_key_exists("render_preferred_choices", $context)) ? (_twig_default_filter((isset($context["render_preferred_choices"]) || array_key_exists("render_preferred_choices", $context) ? $context["render_preferred_choices"] : (function () { throw new RuntimeError('Variable "render_preferred_choices" does not exist.', 88, $this->source); })()), false)) : (false)) && Symfony\Bridge\Twig\Extension\twig_is_selected_choice($context["choice"], (isset($context["value"]) || array_key_exists("value", $context) ? $context["value"] : (function () { throw new RuntimeError('Variable "value" does not exist.', 88, $this->source); })())))) {                    echo " selected=\"selected\"";                }```The 2nd Arg passed when calling ``twig_is_selected_choice`` if the result of ``(isset($context["value"]) || array_key_exists("value", $context) ? $context["value"]``.In that condition, if ``$context['value'] = null, we pass the nullCurrently I got the following error:```Symfony\Bridge\Twig\Extension\twig_is_selected_choice(): Argumentsymfony#2 ($selectedValue) must be of type array|string, null given, called in X:\workspace-novento\novento-vip-lounge\var\cache\admin_dev\twig\01\01615438ee40292438687b29025d08a9.php on line 534```
@fabpot
Copy link
Member

Thank you@raziel057.

@fabpotfabpot merged commitfac84a0 intosymfony:6.0Jun 17, 2022
This was referencedJun 26, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@stofstofstof approved these changes

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

6.0

Development

Successfully merging this pull request may close these issues.

4 participants

@raziel057@fabpot@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp