I am implementing a form to try and add images associated with a product.
Here is the process I am using:
- Perform an AJAX call to get get all potential images.
- Display a thumbnail of each image with a checkbox underneath it.
- The user selects one or more checkboxes and submits the form.
In order to associate the checkbox with the image, I am setting the checkbox name as the URL of the image. That way when the user submits the form any URL's passed to my controller will represent images the user has selected.
On Form Submission however, these URL's are being manipulated ('.' chars become '_' chars). This is posing a bit of a problem:
Example 1:
<label>Use this Image
<input name="http://images.somesite.com/pic/Qmh8Yx6f7Uq1Pnh6mjyfqg.c-o.jpg" type="checkbox">
</label>
On submission however, in my controller when I print out $this->request->data
Array(
[http://images_somesite_com/pic/Qmh8Yx6f7Uq1Pnh6mjyfqg_c-o_jpg] => on
)
I can't use a str_replace('_', '.', $url), because some image's URL's naturally have an underscore in them.
Example 2
<label>Use this Image
<input name="http://ecx.images-amazon.com/images/I/71LJdh3kWnL._SL1390_.jpg" type="checkbox">
</label>
becomes
Array(
[http://ecx_images-amazon_com/images/I/71LJdh3kWnL__SL1390__jpg] => on
)
Is there a way to prevent CakePHP from manipulating these input names before they get passed to the controller?
Thanks!