mothership-ec / cog

Cog
Other
2 stars 3 forks source link

array_merge resets integer keys #455

Closed kuiche closed 9 years ago

kuiche commented 9 years ago

This came about due to a problem from within commerce. Try creating a product which has variants with values which look like integers. For example "Value":"20".

Then try assigning to a page using the Productoption Field. If you look at the generated select box, the values which look like numbers will have wrong values. Something like <option value="4">20</option> where the value should be 20.

This is due to array_merge resetting integer keys. This change means that integer keys are preserved.

thomasjthomasj commented 9 years ago

I may be wrong but would using a plus operator not work and be a more elegant solution?

e.g.

$choices = ['none' => 'None'] + $choices;
kuiche commented 9 years ago

hmm, i thought that basically just did an array merge but i defiantly could be wrong.

Edit: you were right