Strange behavior of sfWidgetFormDmPaginatedDoctrineChoice: losing related records

39 views
Skip to first unread message

Jarek Rencz

unread,
Apr 26, 2013, 2:24:31 AM4/26/13
to diem-...@googlegroups.com
Hi,

could you please confirm if the same happens in your case:
After saving a form, in which sfWidgetFormDmPaginatedDoctrineChoice (default doctrine widget for many to many relations in diem 5.4) is present all records, that were connected to edited record, and were not on first page of widgets' paginated list of records are no longer connected.

I took a look at the code (in Base<ModelName>Form::save<RealtionName>List method) and there's nothing that would prevent such bahavior because $values passed to this method aro only a subset of those 20 (or any other max_per_page): let's say 10 of them selected.
What is being done by this method is unlinking all but those given form current page of widget.

Look at this scenario:
* set max_per_page to infinite
* select all
* save
* set max_per_page to 10
* refresh
* (off course 10 are selected)
* save
* go to the second page
none on the second page (and following pages) is selected

What's even stranger: try this scenario:
* select something on 1st page, 
* go to 2nd page, selecting another entity 
* go back to 1st page
* save
All entities selected in this scenario are actually selected after save. 
Though those ones on 3rd page and following are unlinked.

The only way I know not to unlink them is to set max_per_page to infinite just before saving (inconvenient) or use old sfWidgetFormDmDoctrineChoice (not optimal for 1000s of entities as it is in my case). 

Tell me please if it happens to you and how do you deal with this.


4levels

unread,
Apr 26, 2013, 2:54:39 AM4/26/13
to diem-...@googlegroups.com
Hi Jarek,

This issue has been around for a while in the master branch.  It's definitely related to the recent jQuery upgrades as it doens't seem to successfully store the other (out of view) selected values.  Those are supposed to be added as hidden fields in the but this somehow stopped working.  I've already spent quite some time investigating this as this is a very inconveniencing issue but I haven't found a solid solution for the problem yet..

For now I'm useing the jquery.chosen plugin on a plain DoctrineChoice widget to overcome this issue in my admin forms..

I'll be very happy to announce here when I manage to get this issue resolved!

Kind regards,

Erik






--
 
---
You received this message because you are subscribed to the Google Groups "diem-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diem-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

TheCelavi

unread,
Apr 27, 2013, 8:33:43 AM4/27/13
to diem-...@googlegroups.com
Dude, please do so. If you need help, contact me. 

Best and good catch on issue.

TheCelavi

unread,
Apr 28, 2013, 9:35:03 AM4/28/13
to diem-...@googlegroups.com
Solved - it is not jQuery, it is PHP.

In diem/dmAdminPlugin/data/generator/dmAdminDoctrineModule/dmAdmin/template/templates/_form_field_pagination.php

LINE 4 change to:

<div class="dm_form_pagination {field: '[?php echo $field?]', link: '[?php echo $link?]', selection:  [[?php echo ($form->getDefault($field)) ? implode(',',$form->getDefault($field)) : ''; ?] ], currentPage: [?php echo $pager->getPage()?], lastPage: [?php echo $pager->getLastPage()?]}">

Clear cache and that's it.

All the best,
TheCelavi
Reply all
Reply to author
Forward
0 new messages