Skip to content
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

add missing double-quotes to extra_fields output message #28840

Merged

Conversation

danielkay
Copy link

Q A
Branch? 2.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

When using the extra_fields_message option on FormTypes to include the extra_fields items in the message, the output included some superfluous (or, perhaps, missing?) quotes. This resulted in some strange output: This form should not contain extra fields: notes1\", \"notes2\", \"notes3.

This PR removes the quotes and instead implodes the extra_fields array using merely ', ' as the glue, resulting in the output: This form should not contain extra fields: notes1, notes2, notes3.

@danielkay danielkay changed the title uremove superfluous double-quotes from extra_fields output message remove superfluous double-quotes from extra_fields output message Oct 12, 2018
@fabpot
Copy link
Member

fabpot commented Oct 12, 2018

I think the intention was to have something like This form should not contain extra fields: "notes1", "notes2", "notes3"

@zanbaldwin
Copy link
Member

Congrats on your first Symfony pull request! 🎉

For the merger team: an alternative could be add the extra quotes before and after the imploded fields, but I agree with the style proposed (it's unlikely that form field names will contain commas, and the extra quotes get escaped in APIs using JSON format making it look ugly).

Status: Reviewed

@danielkay
Copy link
Author

@fabpot Unfortunately it isn't doing so... I feel we should take the code one way or the other - would with quotes or without quotes be better? Without the first and last quote feels weird...

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

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

you can already hijack the format by submitting e.g. 'foo","bar' => 'val', so not caring about quotes here seems fine.

@xabbuh xabbuh added the Form label Oct 15, 2018
@fabpot
Copy link
Member

fabpot commented Oct 16, 2018

I would add the missing quotes instead of removing them to be consistent with the way we display other error messages.

@nicolas-grekas nicolas-grekas added this to the 2.8 milestone Oct 17, 2018
@danielkay danielkay force-pushed the fix/erroneous-quotes-in-extra_fields-output branch from ade8f68 to 2379b40 Compare October 17, 2018 11:29
@danielkay danielkay changed the title remove superfluous double-quotes from extra_fields output message add missing double-quotes to extra_fields output message Oct 17, 2018
@danielkay
Copy link
Author

added missing quotes as per suggestion from @fabpot

->setInvalidValue($form->getExtraData())
->setCode(Form::NO_SUCH_FIELD_ERROR)
->addViolation();
} else {
$this->buildViolation($config->getOption('extra_fields_message'))
->setParameter('{{ extra_fields }}', implode('", "', array_keys($form->getExtraData())))
->setParameter('{{ extra_fields }}', '"'.implode(', ', array_keys($form->getExtraData())).'"')
Copy link
Contributor

Choose a reason for hiding this comment

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

here '", "' should remain as glue also right

Copy link
Author

Choose a reason for hiding this comment

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

Ooops, well spotted 👍

@danielkay danielkay force-pushed the fix/erroneous-quotes-in-extra_fields-output branch 3 times, most recently from 3ef528c to d1d2c48 Compare October 17, 2018 12:05
@fabpot fabpot force-pushed the fix/erroneous-quotes-in-extra_fields-output branch from d1d2c48 to 9e74141 Compare October 17, 2018 13:53
@fabpot
Copy link
Member

fabpot commented Oct 17, 2018

Thank you @danielkay.

@fabpot fabpot merged commit 9e74141 into symfony:2.8 Oct 17, 2018
fabpot added a commit that referenced this pull request Oct 17, 2018
…danielkay)

This PR was squashed before being merged into the 2.8 branch (closes #28840).

Discussion
----------

add missing double-quotes to extra_fields output message

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

When using the extra_fields_message option on FormTypes to include the extra_fields items in the message, the output included some superfluous (or, perhaps, missing?) quotes. This resulted in some strange output: `This form should not contain extra fields: notes1\", \"notes2\", \"notes3`.

This PR removes the quotes and instead implodes the extra_fields array using merely ', ' as the glue, resulting in the output: `This form should not contain extra fields: notes1, notes2, notes3`.

Commits
-------

9e74141 add missing double-quotes to extra_fields output message
This was referenced Nov 3, 2018
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.

None yet

7 participants