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

Appearance settings

[Form] Allow int in Form::add #44266

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

Closed
wants to merge 1 commit into from
Closed

[Form] Allow int in Form::add #44266

wants to merge 1 commit into from

Conversation

franmomu
Copy link
Contributor

@franmomu franmomu commented Nov 25, 2021

Q A
Branch? 6.0
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #...
License MIT
Doc PR symfony/symfony-docs#...

Here in the same function, there is this check:

if (!$child instanceof FormInterface) {
if (!\is_string($child) && !\is_int($child)) {
throw new UnexpectedTypeException($child, 'string or Symfony\Component\Form\FormInterface');
}

The problem is that using strict types and CollectionType it throws a TypeError because it adds the data as array with integer keys and then the FormResizerListener re-add them for ordering:

foreach ($data as $name => $value) {
$form->add($name, $this->type, array_replace([
'property_path' => '['.$name.']',
], $this->options));
}
}

here $name is an int.

Or the FormResizerListener should cast the $name to string.

@fancyweb
Copy link
Contributor

Ref #32828

Does this mean we have to add |int on every methods where we expected casting?

@franmomu
Copy link
Contributor Author

sorry for the noise, I think it is fine since FormResizerListener does not have the strict type declaration.

@franmomu franmomu closed this Nov 25, 2021
@franmomu franmomu deleted the patch-3 branch November 25, 2021 09:47
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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.