Skip to content

Remove strict true === $user['showEmail'] on preSubmit #12072

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

Merged
merged 1 commit into from
Aug 1, 2019

Conversation

jbdelhommeau
Copy link
Contributor

@jbdelhommeau jbdelhommeau commented Aug 1, 2019

On the pre submit example. Strict condition will be used. true === $user['showEmail'].

In pre submit value of data are not normalized. Strict operator true === $user['showEmail'] is wrong.

If we want used strict operator we can use: '1' === $user['showEmail']. but in case of checkbox is not checked the key showEmail is not set.

I prefere use this condition: isset($user['showEmail']) && $user['showEmail'] or maybe false === empty($user['showEmail']) ?

@OskarStark
Copy link
Contributor

@xabbuh this must go in 3.4 branch, right?

@xabbuh
Copy link
Member

xabbuh commented Aug 1, 2019

Yes

@OskarStark OskarStark added this to the 3.4 milestone Aug 1, 2019
@OskarStark OskarStark added the Form label Aug 1, 2019
@OskarStark OskarStark changed the base branch from master to 3.4 August 1, 2019 10:12
@OskarStark
Copy link
Contributor

OskarStark commented Aug 1, 2019

Thanks for fixing this bug Jean-Baptiste 👏 and congrats on your first contribution to the Symfony-Docs 🎉

@OskarStark OskarStark merged commit 122ccaa into symfony:3.4 Aug 1, 2019
OskarStark added a commit that referenced this pull request Aug 1, 2019
…delhommeau)

This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #12072).

Discussion
----------

Remove strict true === $user['showEmail'] on preSubmit

<!--

If your pull request fixes a BUG, use the oldest maintained branch that contains
the bug (see https://symfony.com/roadmap for the list of maintained branches).

If your pull request documents a NEW FEATURE, use the same Symfony branch where
the feature was introduced (and `master` for features of unreleased versions).

-->

On the pre submit example. Strict condition will be used. `true === $user['showEmail']`.

In pre submit value of data are not normalized. Strict operator `true === $user['showEmail']` is wrong.

If we want used strict operator we can use: `'1' === $user['showEmail']`. but in case of checkbox is not checked the key `showEmail` is not set.

I prefere use this condition: `isset($user['showEmail']) && $user['showEmail']` or maybe `false === empty($user['showEmail'])` ?

Commits
-------

122ccaa Remove strict true === $user['showEmail'] on preSubmit
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.

4 participants