CodeIgniter Forums
CI 3 form helper add new lines after form_element - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: CI 3 form helper add new lines after form_element (/showthread.php?tid=63418)



CI 3 form helper add new lines after form_element - matthieubrunet - 10-28-2015

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


RE: CI 3 form helper add new lines after form_element - mwhitney - 10-28-2015

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?