I have an inline admin where I can add new items in a table view. If I press the "add" button then I get a type error since I moved to Symfony 6. It worked fine with Symfony 5.4 as there was no string typehint on Symfony's FormBuilder::get.
Actual results
A dump of
public function current(): FormBuilderInterface
{
if ($this->iterator->current() === 0) {
dd($this);
}
return $this->formBuilder->get($this->iterator->current());
}
From what I can tell we cannot guarantee that $this->iterator->current() within FormBuilderIterator will actually be a string. In my case its an integer and this seems legit. The problematic form field is an expanded choice field with checkboxes and the children of this form are indexed with integers.
I checked it and casting to string there solves the issue for me. Shall I create a PR for this?
public function current(): FormBuilderInterface
{
return $this->formBuilder->get((string) $this->iterator->current());
}
Environment
Subject
Type error caused by
FormBuilderIterator
Minimal repository with the bug
?
Steps to reproduce
I have an inline admin where I can add new items in a table view. If I press the "add" button then I get a type error since I moved to Symfony 6. It worked fine with Symfony 5.4 as there was no
string
typehint on Symfony'sFormBuilder::get
.Actual results
A dump of
From what I can tell we cannot guarantee that
$this->iterator->current()
withinFormBuilderIterator
will actually be a string. In my case its an integer and this seems legit. The problematic form field is an expanded choice field with checkboxes and the children of this form are indexed with integers.I checked it and casting to string there solves the issue for me. Shall I create a PR for this?