-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
The name "Doctrine\ODM\MongoDB\ArrayCollectionelements" contains illegal characters. #8148
Comments
I changed the field description to: ->add('hotelInfoTranslations', CollectionType::class, [
'modifiable' => true,
'by_reference' => false,
]) By removing
And I can see the list of embedded objects and related data. But what is strange is that I can see two "Add element" buttons at the bottom of the list (which is weird). Clicking any of them opens the window with the form, which is expected, but element is not added. There are two methods that exist for adding and replacing elements: /**
* @param iterable<HotelInfoTranslation> $hotelInfoTranslations
*/
public function setHotelInfoTranslations(iterable $hotelInfoTranslations): self
{
$this->hotelInfoTranslations = new ArrayCollection((array)$hotelInfoTranslations);
return $this;
}
public function addHotelInfoTranslation(HotelInfoTranslation $hotelInfoTranslation): self
{
$this->hotelInfoTranslations->add($hotelInfoTranslation);
return $this;
} here is the request:
and the response is: {
"result": "ok",
"objectId": "000000000000023c0000000000000000",
"objectName": "App\\Document\\HotelInfoTranslation:000000000000023c0000000000000000"
} But the object itself is embedded, it probably should not work like that |
Closing as invalid. Resolved: /**
* @param iterable<HotelInfoTranslation> $hotelInfoTranslations
*/
public function setHotelInfoTranslations(iterable $hotelInfoTranslations): self
{
$this->hotelInfoTranslations = $hotelInfoTranslations instanceof Collection
? $hotelInfoTranslations
: new ArrayCollection($hotelInfoTranslations);
return $this;
} |
Environment
Dev, os x 14.1.2 (23B92), Docker
Sonata packages
show
Symfony packages
show
PHP version
Subject
The definition of field:
The definition of the Document field:
Minimal repository with the bug
Steps to reproduce
I tried to display a collection of Documents (MongoDB) using
use Sonata\Form\Type\CollectionType;
, but when trying to add new element, server returns HTTP 500Expected results
Actual results
The text was updated successfully, but these errors were encountered: