Select POST array Issues

Permalink
So, I've been banging my head against the wall for a good few hours now, so I thought I'd bring this up here:

Simply put, if you use selects and an array of values, you get screwed.

See the below image for what I'm talking about. So, I have a dashboard page that people can add different items to. They can add and remove in here. This is a standard type of setup for join tables.

Now, let's say I change some things, then I post this and come back to this page. THIS is what I get: the items all default to the same select option. This clearly is broken. You can see the var dump showing the 4 fields above them all, showing the values they should be in the image.

I think the issue is within the helper, where it defaults to the first item in the array for the value (WHY would they do this? It's going to be wrong 50% of the time or more for more than one item).

my code:
<td><?php echo $add_row_icon . ' ' . $remove_row_icon;?><?php echo $form->hidden('eccID[]', (int) $category['eccID']);?></td>
<td><?php echo $form->select('category[]', $category_options, $category['ecID']); ?></td>
<td><?php echo form->select('subcategory[]',$subcategory_options,$category['scID']);?><?php echo $form->hidden('set[]',$category['fsName']);?></td>
<td><?php echo $form->select('group[]', $group_options, $category['gID']); ?></td>


From the form helper:
if (is_array($val)) {
         $valueOrArray = $val[0];
      }


Now, I am researching ways to fix this myself (and I'll submit a fix if I do), but I am absolutely mind-boggled that no one has run into this previously. Is there something I am doing wrong here? Any advice?

1 Attachment

 
JohntheFish replied on at Permalink Reply
JohntheFish
I posted a hack of the form helper that removes the sticky behaviour. It may help (or it may not)

If you look back through the forums you can probably still find it, or you can get it from a pull request at
https://github.com/concrete5/concrete5/pull/601/files...
(The pull got turned down).

I have not kept this in sync with the latest version of the file helper, so if you are using anything added in the file helper in the last few c5 releases you will need to resolve that.