CodeIgniter Forums
form helper and HTML 4 - 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 and HTML 4 (/showthread.php?tid=52094)



form helper and HTML 4 - El Forum - 05-29-2012

[eluser]dwlamb[/eluser]
I'm building an app using HTML 4.01 Transitional for a Doctype. Deploying forms using the Form Helper, code rendered ends with ' //>' Is there a method or something I am missing to have tags not deploy with ' //>' just a simple '>'?


form helper and HTML 4 - El Forum - 05-29-2012

[eluser]Aken[/eluser]
There is no option to change from one to the other. I'd recommend either using an XHTML doctype so the self-closing tags are appropriate, or extend the form helper and replace / change those functions to support your variation.


form helper and HTML 4 - El Forum - 05-29-2012

[eluser]dwlamb[/eluser]
@Aken or anyone

I'm relatively new to CI and OOP. Can you give me the steps to extend the form helper and modify the code so that it does not render ' />'?

There should be a way with any of the helpers to turn-off self-closing tag syntax. Further development of XHTML as a standard is not going to happen and the self-close is not necessary in HTML 5.


form helper and HTML 4 - El Forum - 05-29-2012

[eluser]bluemonsta[/eluser]
You could modify the core helper /system/helpers/form_helper.php and change the endings for each input.

But if you modify the core, it will be removed when you next upgrade CI.

Why not just use the html5 doctype? Or use this one that forces the most up to date doctype in your browser.

Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="utf-8" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;

Of course this assumes that your page is UTF-8 encoded and in english.


form helper and HTML 4 - El Forum - 05-29-2012

[eluser]CroNiX[/eluser]
You can extend helpers rather than modify the core directly, just like controllers, models, etc.


form helper and HTML 4 - El Forum - 05-29-2012

[eluser]dwlamb[/eluser]
But how, precisely? If I go the route of extending the helper, do I create a new function similar to the ones in the Helper and replace the " //>" with ">" to close the tags?


form helper and HTML 4 - El Forum - 05-29-2012

[eluser]bluemonsta[/eluser]
http://ellislab.com/codeigniter/user-guide/general/helpers.html

and look at the 'extending helpers' section near the bottom.


form helper and HTML 4 - El Forum - 05-29-2012

[eluser]InsiteFX[/eluser]
./application/helpers/MY_name_helper.php


form helper and HTML 4 - El Forum - 05-29-2012

[eluser]dwlamb[/eluser]
@bluemonsta

Thanks for the information. That will do nicely.