symfony-collection | jQuery plugin | Web Framework library
kandi X-RAY | symfony-collection Summary
kandi X-RAY | symfony-collection Summary
[NOT MAINTAINED] A jQuery plugin that manages adding, deleting and moving elements from a Symfony form collection
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of symfony-collection
symfony-collection Key Features
symfony-collection Examples and Code Snippets
Community Discussions
Trending Discussions on symfony-collection
QUESTION
I can't believe this hasn't come up for other people, but I'm unable to find a solution.
Let's say I have two entity types, A and B with a one-to-many relationship. A has a collection of Bs.
The form for A has a CollectionType
for the Bs, with a custom entry_type
for B, allow_add
and allow_delete
set to true
. When the form is created/populated/rendered, the Bs' fields are identified by their index in the collection. When the form is posted back, the fields are mapped back onto the B entities according to the index again.
What if the database in the mean time decided to return the Bs in a different order? Then the values get swapped around on the Bs! I can't have that, as other entities will reference the Bs and now they've changed their meaning!
Even if the database doesn't change the order, the same issue appears when a B is deleted: The fields get shifted through the Bs and a different one deleted! (Ok, I'm not a 100% certain this happens, as there's a gap then in the numbering of the posted fields.) I've found this similar question where it does happen when another one is created (Symfony CollectionType regards deletion+creation as a modification of an item), but that sort of drifted from the issue and there's no usable answer.
How do I make sure the form is updating the entities the user actually edited?
I already tried to render the Bs' IDs as a HiddenType
, but then the form rightfully complains that the ID has no setter. It would probably force an ID on the wrong B anyways and Doctrine doesn't like that. I suppose I could add the Bs as unmapped and copy the values over to the correct objects manually, but that would defeat a good chunk of Symfony's form system.
I've used CollectionType
before, but not for entities that are referenced elsewhere. I would then delete all of the previous entities and create the collection anew from the posted data. But I can't do that now, can I?
ANSWER
Answered 2020-Nov-12 at 20:16Since doctrine 2.1, it's possible to change how associations are indexed. This will allow you to use the id
as the collection key (as the field has to be unique):
QUESTION
The last composer update completely broken my project based on Symfony5:
php.CRITICAL: Uncaught Error: Argument 1 passed to Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter::__construct() must be an instance of Doctrine\Common\Persistence\ManagerRegistry or null, instance of Doctrine\Bundle\DoctrineBundle\Registry given
I've already updated all the references of Doctrine\Bundle\DoctrineBundle\Registry to Doctrine\Common\Persistence\ManagerRegistry a long time ago, according to the Symfony documentation
Any help would be appreciated
List of installed packages:
...ANSWER
Answered 2020-Aug-25 at 10:58- Update Php Version on your system to 7.4
- Run composer upgrade
QUESTION
I'm currently strugglin with rendering of my form type. I have an Order entity and OrderItems entity, which both have their own Type.
OrderType:
...ANSWER
Answered 2020-Aug-21 at 07:36A CollectionType give you only a prototype
Then, you must add javascript to use this prototype and create multiple forms of your collection
All is in the doc 😉 : https://symfony.com/doc/current/form/form_collections.html#allowing-new-tags-with-the-prototype
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install symfony-collection
the jquery plugin itself, it should be located with your assets
a twig form theme that will ease use of it, it should be located in your views
To automate the plugin download and installation, edit composer.json and add:.
symfony-collection form theme will be installed in app/Resources/views
symfony-collection jquery plugin will be installed in web/js.
Replace dev-master by the current stable version.
Put script handlers before Symfony's installAssets if you wish to benefit from your assets optimizations.
Add app/Resources/views/jquery.collection.html.twig and web/js/jquery.collection.js to your .gitignore
vendor/ninsuo/symfony-collection/jquery.collection.js in your assets (for example in web/js)
vendor/ninsuo/symfony-collection/jquery.collection.html.twig in your views (for example in app/Resources/views)
You'll have to move:.
node_modules/symfony-collection/jquery.collection.js in your assets (for example in web/js).
node_modules/symfony-collection/jquery.collection.html.twig wherever you want in your views (for example in app/Resources/views)
You'll have to move:.
bower_components/symfony-collection/jquery.collection.js in your assets (for example in web/js)
bower_components/symfony-collection/jquery.collection.html.twig in your views (for example in app/Resources/views)
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page