Welcome Guest, Not a member yet? Register   Sign In
CI 3 form helper add new lines after form_element
#1

Hi there,
In CI 2, the following code
PHP Code:
echo "before" form_input("test") . "after"
Used to return :
Code:
before<input type="text" name="test" />after
In CI 3, it returns :
Code:
before<input type="text" name="test" />
after

It may be a feature, but it's a bug to me, as I use it in javascript string, and javascript doesn't like new line in the middle of a string.

Thanks
Reply
#2

While you can quite easily setup a MY_form_helper to prevent the newline outputs, you should be passing the output through a function (like json_encode(), for example) to ensure the output is safe to use in a JavaScript string. For an example of why this might be important, what would happen to your code if the output of form_input() used single quotes instead of double quotes?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB