Welcome Guest, Not a member yet? Register   Sign In
form_open attributes string bug
#1

[eluser]Unknown[/eluser]
The form_open helper function doesn't cope with json_encoded data.

When adding custom data-x attributes to any element, my understanding is that it's quite usual to use single quotes and to json encode the value because json_encoded data will have double quotes in it.

Code:
$html = '<a href="/">Bar</a>';
// I did add
// data-foo=\''.json_encode($foo_array).'\'
// to the above tag but code parser has stripped it out.

The form_open helper function accepts an array of key=>value pairs for adding attributes to the form tag. It double-quotes all values in the resulting string which breaks custom data attributes like this.

There is a workaround of passing a string instead of an array but that's clearly more cumbersome than using an array.

Is there any possibility or need to alter the helper function such that it either single-quotes data attributes or checks for quotes in the value and switches where necessary.




Theme © iAndrew 2016 - Forum software by © MyBB