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

[Form] render hidden empty inputs for checkboxes#20210

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

Closed
xabbuh wants to merge1 commit intosymfony:2.7fromxabbuh:issue-20179

Conversation

xabbuh
Copy link
Member

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#20179
LicenseMIT
Doc PR

This ensures that a form is always considered submitted even if it contains only checkboxes which all haven't been checked by the user.

@xabbuh
Copy link
MemberAuthor

Looks like not all tests are passing.

This ensures that a form is always considered submitted even if itcontains only checkboxes which all haven't been checked by the user.
@backbone87
Copy link
Contributor

The hidden input should not be added for expanded multiple choice types

@dmaicher
Copy link
Contributor

@xabbuh I think this will also fix my issue then that I reported a while back:#14938

👍

@@ -85,7 +85,7 @@
{%- endblock choice_widget_options -%}

{%- block checkbox_widget -%}
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
<input type="hidden" name="{{ full_name }}" /><input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
Copy link
Contributor

@dmaicherdmaicherOct 13, 2016
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

just to understand: this will render two input fields with the same name then, right? So if the checkbox is ticked then the browser will send its value as it's a successor in the DOM?

Or will it send both? likename=&name=checkbox_value

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It will send both.

@xabbuh
Copy link
MemberAuthor

@backbone87 You are right. Sending the hidden field there too would lead to wrong data. However, this also means that we would not be able to fix the underlying issue in all cases. Question is should we still follow this approach to solve at least some of them?

ping @symfony/deciders

@backbone87
Copy link
Contributor

i dont even know how to solve the case with extended multiple choice, maybe one hidden input with the "non-array"-name will work, to produce POST data like this:NAME=&NAME[]=VALUE1&NAME[]=VALUE2, but i dont know what php does with that when parsed

@ro0NL
Copy link
Contributor

@backbone87
Copy link
Contributor

backbone87 commentedOct 13, 2016
edited
Loading

another approach to this (which is also used within Contao, though for a different purpose) could be a separate POST variable containing submitted fields.

<input type="hidden" name="_submitted[]" value="some.field" />

this would then be handled within the RequestHandler

$data =$_POST[$name];foreach($_POST['_submitted']as$path) {$propertyAccessor->setValue($data,$path,null);}

´
this is kind of recreating the full structure of the forms mapping array with elements that cannot be represented with application/www-url-form-encoded (however a POST with application/json, can represent these, thats why the RequestHandler for application/www-url-form-encoded is responsible for "sanitizing" the form mapping array)

the benefit of this is the full transparency for any form type, because the root cause of this problem is the application/www-url-form-encoded can only work with strings and arrays/maps and no other data type (like application/json)

Koc reacted with thumbs up emoji

@javiereguiluzjaviereguiluz added this to the3.3 milestoneNov 7, 2016
@HeahDude
Copy link
Contributor

I think we can close here in favor of#17771.

@xabbuh
Copy link
MemberAuthor

xabbuh commentedDec 3, 2016
edited
Loading

Closing in favour of#17771.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dmaicherdmaicherdmaicher left review comments

Assignees
No one assigned
Projects
None yet
Milestone
3.3
Development

Successfully merging this pull request may close these issues.

8 participants
@xabbuh@backbone87@dmaicher@ro0NL@HeahDude@javiereguiluz@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp