CodeIgniter Forums
'form helper' help - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: 'form helper' help (/showthread.php?tid=14641)



'form helper' help - El Forum - 01-09-2009

[eluser]RS71[/eluser]
Is there a way to have the output of a form_dropdown helper be on a single line instead of multiple ones?

I'm trying to use the form helper with javascript (jQuery) but once it outputs multiple lines, it breaks the javascript.


'form helper' help - El Forum - 01-09-2009

[eluser]Michael Wales[/eluser]
Open system/helpers/form_helper.php, find the form_dropdown() function and copy it.

Create a new file application/helpers/MY_form_helper.php and paste that function in there.

Remove the \n from the lines of code that concatenate the string.

Weep at the power that is CodeIgniter Helper Extending.


'form helper' help - El Forum - 01-10-2009

[eluser]RS71[/eluser]
Thank you for your reply Michael.

I am still new to CodeIgniter, but what if I did not want to change the function permanently? What if I wanted to have maybe a function form_dropdown_n() or something similar that would output the html without new lines?


'form helper' help - El Forum - 01-10-2009

[eluser]jtkendall[/eluser]
RS71, follow the same instructions as Michael provided and just change the function name in your MY_form_helper.php file, then it won't override the default CI function.


'form helper' help - El Forum - 01-10-2009

[eluser]xwero[/eluser]
The same method can be used but instead of keeping the function name alter it, et voila.