ninsuo / symfony-collection

[NOT MAINTAINED] A jQuery plugin that manages adding, deleting and moving elements from a Symfony form collection
https://symfony-collection.fuz.org/
MIT License
444 stars 88 forks source link

NINSUO Symfony Collection Crashes after 100 Records #127

Open ghost opened 6 years ago

ghost commented 6 years ago

I'm doing an asset management system and during the testing phase, the tester reported that she couldn't add any assets to a person anymore once the asset count reaches 100. I tried raising the max to 1000 to no avail. Upon closer look, it seems that the javascript itself crash causing the control buttons to not appear. These include the add and delete button. Uncaught RangeError: Maximum call stack size exceeded at r.fn.init.push (<anonymous>) at ga.select (jQuery.js:2) at Function.ga [as find] (jQuery.js:2) at r.fn.init.find (jQuery.js:2) at HTMLDivElement.<anonymous> (jquery.collection.js:735) at Function.each (jQuery.js:2) at r.fn.init.each (jQuery.js:2) at String.<anonymous> (jquery.collection.js:730) at Function.each (jQuery.js:2) at setRightPrefix (jquery.collection.js:728)

ninsuo commented 6 years ago

Hey there,

Set max: 999 so the maximum elements won't be reached, there must be a bug with max option.

Cheers, Alain

ghost commented 6 years ago

Nope still won't work, maybe I'm doing something wrong here:

        $('.asset_collection').collection({ allow_duplicate: false,
                                            allow_up: false,
                                            allow_down: false,
                                            max: 999,
                                            add_at_the_end: true,
                                            up: '<a href="#" class="btn btn-primary with-margin"><i class="fas fa-chevron-up"></i></a>',
                                            down: '<a href="#" class="btn btn-primary with-margin"><i class="fas fa-chevron-down"></i></a>',
                                            add: '<a href="#" class="btn btn-primary with-margin"><i class="fas fa-plus"></i></a>',
                                            remove: '<a href="#" class="btn btn-danger with-margin"><i class="fas fa-trash-alt"></i></a>',
                                            duplicate: '<a href="#" class="btn btn-primary with-margin"><i class="fas fa-copy"></i></a>'
        });
ninsuo commented 6 years ago

Okey, there may be an issue with recursions when there are too many children.

You can eventually use a hidden position field in your entity instead, because much less code is executed.

See the example here: https://symfony-collection.fuz.org/symfony3/basic/positionField

A

jkabat commented 6 years ago

@Horzta Please make sure it is not PHP issue - I have not tried symfony-collection yet, but I've dealt with similar issue in the past.

If your FORM is broken you should probably check max-input-vars INI setting.

http://php.net/manual/en/info.configuration.php#ini.max-input-vars