MultiSelect with sorting saves wrong data

edited September 2017 in Bug Reports
If I have a many-to-many model relationship and I add a new related item to the selection (by clicking the 'Add' button) and then save the model the data that is saved save for the "new" item which it takes the next item out of the array of options prior to it being added. I may have tracked it down to almost a double initializing of the supercomboselect item. Has anyone else run into this sort of oddity?

Comments

  • edited 3:37AM
    This seems to be a bug. I've posted a fix in the develop branch for what I noticed when debugging your issue:
    https://github.com/daylightstudio/FUEL-CMS/commit/7f743339bb8e59084fabeaefd136764c1d57d229
  • edited 3:37AM
    I tried the change but no luck. What I'm seeing happening is when I add a new item (let's say "Keith") and when I hit save it is using the very next item in the list as the item I chose (in this case it's "Kyra"). So it was basically looking for Keith in the original list but couldn't find it so it presumed it's the next item in the list.
  • edited 3:37AM
    Is it selecting the item you just added?
  • edited 3:37AM
    No, if I have a pre-existing list of options: alpha, beta, theta and none of those records have i selected in my multi-select. When i click the 'Add' button and create a record for omega upon closing the modal the select2 list looks exactly as it should but when I hit save on my record it now populates the select2 list as having theta selected. it's almost as if there's an index it's using to get the position of the added record but the added record has never been added to the index so it takes the next one in order. My presumption is the issue is in the javascript somewhere
  • edited 3:37AM
    So you are using a "select2" instead of the "multi" field type to handle this? Does this happen if you use a "multi" field type?
  • edited 3:37AM
    it's a $has_many relationship in the model so it's using the default from FUEL -- i presume that's the multi. If I explicitly tell it the type of 'select2' it becomes a select2 dropdown not a multi.
  • edited 3:37AM
    That's correct. So are you experiencing this issue with both the multi and the select2 or just the select2?
  • edited 3:37AM
    My bad, i was referring to it as select2 and it's actually the supercombo_select. Here's what I am seeing in my $_POST args for the has_many field "personnel":

    [supercomboselect_search] =>
    [undefined] => 77
    [personnel] => Array
    (
    [0] => 39
    [1] => 40
    [2] => undefined
    [3] => 25
    )

    [sorting_personnel] => %5B%2239%22%2C%2240%22%2C%2276%22%2C%2277%22%5D
    [exists_personnel] => 1

    what happens is I have a list where IDs 39 & 40 are already selected and then I add 1 or 2 more via the related model. So the 'sorting_personnel' field is right but the 'personnel' field is wrong and that's what appears to be used to save the data. Unfortunately if I use on_before or on_after hooks to set the 'personnel' to be the same values as sort_personnel (as an array) the ordering isn't actually set... I think the 'personnel' field is supposed to have the ordering
  • edited 3:37AM
    This looks like it may be an issue with that particular field type with sorting set to true and may take a bit of time to debug.
Sign In or Register to comment.