Comments (2)
I changed the field description to:
->add('hotelInfoTranslations', CollectionType::class, [
'modifiable' => true,
'by_reference' => false,
])
By removing
'edit' => 'inline',
'inline' => 'table',
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:
curl 'http://localhost:8081/admin/app/hotelinfotranslation/create?uniqid=s658c948b1c63f' \
-H 'Accept: application/json' \
-H 'Accept-Language: uk,en-US;q=0.9,en;q=0.8,ru;q=0.7' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-H 'Cookie: sonata_sidebar_hide=0; PHPSESSID=f5dcffa54ecc75eb992c78491334e2f3' \
-H 'Origin: http://localhost:8081' \
-H 'Pragma: no-cache' \
-H 'Referer: http://localhost:8081/admin/app/hotel/12/edit?_tab=tab_s658c948a0e66d_1426885114_4' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw 's658c948b1c63f%5BhotelName%5D=TestTestTest&s658c948b1c63f%5BhotelDescription%5D=TestTestTestTestTestTestTestTestTestTestTest&s658c948b1c63f%5BhotelAddressStreet%5D=TestTestTestTestTest&s658c948b1c63f%5BhotelAddressCity%5D=TestTestTestTestTest&s658c948b1c63f%5Blanguage%5D=ab&s658c948b1c63f%5B_token%5D=669c012c0.KAUInNP4ASSdQgKsClUrh5d5LPdAWC6bPBpdeQ5fJ1o.RExA5eGoMAnVA0neXAoa7aJKQYQWb0_wXXUoF2wxHjtrZ3vMnLxIbMkkcQ&_xml_http_request=true' \
--compressed
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
from sonataadminbundle.
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;
}
from sonataadminbundle.
Related Issues (20)
- Datepicker calendar window is placed incorrectly if the field is at the bottom HOT 1
- Unable to use a custom message to be shown as the error flash message HOT 2
- admin-lte js package 2.4 is concerned by known critical vulnerabilities HOT 5
- Customizable breadcrumbs HOT 1
- ChoiceFieldMaskType with expanded: true does not work well when icheck is disabled HOT 2
- ModelList btn_delete bug when hit Enter key HOT 2
- Allow customize sonata-admin webpack build(s) HOT 1
- Rebuild template layer HOT 6
- Submitting a form with ->render instead of ->renderWithExtraParams does not work HOT 9
- Security threat within symfony/twig-bridge HOT 3
- SAML SSO and SCIM to the Admin Panel HOT 2
- Using SubClasses in admins create either not handable translation ids or urly urls HOT 2
- Overriding createQuery doesn't seem to be a thing anymore HOT 2
- symfony 7 compatibility HOT 1
- Problem 1 - symfony/security-acl[v3.1.0, ..., v3.1.2] require symfony/security-core ^3.4|^4.4|^5.0 -> found symfony/security-core[v3.4.0, ..., v3.4.49, v4.4.0, ..., v4.4.48, v5.0.0, ..., v5.4.30] but it conflicts with your root composer.json require (7.0.*). HOT 2
- Customise error message for ModelManagerException HOT 1
- CSRF token error occurs on record creation after applying symfony/security-http security patch HOT 4
- `Uncaught TypeError: __webpack_require__.O is not a function` after upgrading to a version >=4.24.0 HOT 8
- List add item using inline form HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sonataadminbundle.