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] Mix attr option between guessed options and user options#22936

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:2.7fromyceruto:fix_19871
Jun 3, 2017

Conversation

@yceruto
Copy link
Member

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

// user options may override guessed options
if ($typeGuess) {
$options =array_merge($typeGuess->getOptions(),$options);
$options =array_replace_recursive($typeGuess->getOptions(),$options);
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if it is a good idea to apply this "globally". For theattr option, doing a recursive merge does work. But this may not be the case for all other options where the usage of some keys may be mutually exclusive.

Copy link
Member

Choose a reason for hiding this comment

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

What we can do: First merge all guess options recursively and then do the merge here as before.

HeahDude reacted with thumbs up emoji
Copy link
MemberAuthor

@ycerutoycerutoMay 29, 2017
edited
Loading

Choose a reason for hiding this comment

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

But this may not be the case for all other options where the usage of some keys may be mutually exclusive.

Sorry :/ I don't see what I missing here, would you show me an example, please? I've done a simple test (https://3v4l.org/5FvnM) but I don't see what is wrong witharray_replace_recursive() function :/

Copy link
Member

Choose a reason for hiding this comment

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

seehttps://3v4l.org/JOK0d

We don't know if it is allowed to use both keysbaz andbar at the same time for thefoo option.

Copy link
Member

@xabbuhxabbuhMay 29, 2017
edited
Loading

Choose a reason for hiding this comment

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

I suggest to change the code as follows:

$guessedOptions =array();if (null !==$pattern) {$guessedOptions =array_replace_recursive(array('attr' =>array('pattern' =>$pattern)),$guessedOptions);}if (null !==$maxLength) {$guessedOptions =array_replace_recursive(array('attr' =>array('maxlength' =>$maxLength)),$guessedOptions);}if ($requiredGuess) {$guessedOptions =array_merge(array('required' =>$requiredGuess->getValue()),$guessedOptions);}if ($typeGuess) {$guessedOptions =array_replace_recursive($typeGuess->getOptions(),$guessedOptions);}// user options may override guessed options$options =array_merge($guessedOptions,$options);

Copy link
MemberAuthor

@ycerutoycerutoMay 29, 2017
edited
Loading

Choose a reason for hiding this comment

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

Following the first assumption:

But this may not be the case for all other options where the usage of some keys may be mutually exclusive.

Still we can passfalse to the user option and it not will be displayed, i.e.:

$form->add('foo',null,array('foo' =>array('baz' =>false,'bar' =>'foobar')));//...$customGuessedOptions =array('foo' =>array('baz' =>'foobaz'));

Copy link
Member

Choose a reason for hiding this comment

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

My comment above should have usedarray_replace_recursive() for the type guess too (I updated it).

Copy link
Member

Choose a reason for hiding this comment

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

Losing themaxlength attribute when passing theattr option is expected IMO as you opted to be more clever than the guessers for theattr option.

Copy link
MemberAuthor

@ycerutoycerutoMay 29, 2017
edited
Loading

Choose a reason for hiding this comment

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

Losing the maxlength attribute when passing the attr option is expected IMO [...]

It's not a BC break? before this PR it's not true and the issue description proposes mixattr options also between guessed options and populated options, so now the one that is lost is me :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Losing the maxlength attribute when passing the attr option is expected

It should not as it could trigger an unwanted deprecation.

@nicolas-grekasnicolas-grekas added this to the2.7 milestoneMay 29, 2017
@ycerutoyceruto changed the title[Form] Override options recursively[Form] Mix attr option between guessed options and user optionsMay 29, 2017
@yceruto
Copy link
MemberAuthor

yceruto commentedMay 29, 2017
edited
Loading

I've updated the solution mixingattr options between type-guess options and user options. It's already supported betweenmaxlength/pattern and user options attributes.

Status: Needs Review

@fabpot
Copy link
Member

Thank you@yceruto.

@fabpotfabpot merged commit84f5de9 intosymfony:2.7Jun 3, 2017
fabpot added a commit that referenced this pull requestJun 3, 2017
…tions (yceruto)This PR was merged into the 2.7 branch.Discussion----------[Form] Mix attr option between guessed options and user options| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#19871| License       | MITCommits-------84f5de9 mix attr options between type-guess options and user options
@ycerutoyceruto deleted the fix_19871 branchJune 4, 2017 18:56
This was referencedJun 6, 2017
@fabpotfabpot mentioned this pull requestJul 4, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhxabbuh approved these changes

+1 more reviewer

@HeahDudeHeahDudeHeahDude left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

6 participants

@yceruto@fabpot@xabbuh@HeahDude@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp