Should I use CodeIgniter html or form helper class? Should I use CodeIgniter html or form helper class? codeigniter codeigniter

Should I use CodeIgniter html or form helper class?


Helper functions are provided only for ease they are not necessary to use it is always better to use simple html since using helper would definitely create a overhead on server on the other hand advantage of using these function is your code becomes minified e.g read this text that i have copied from their documentation

form_prep()

Allows you to safely use HTML and characters such as quotes within form elements without breaking out of the form. Consider this example:

$string = 'Here is a string containing "quoted" text.';

<input type="text" name="myform" value="$string" />
Since the above string contains a set of quotes it will cause the form to break. The form_prep function converts HTML so that it can be used safely:

<input type="text" name="myform" value="<?php echo form_prep($string);?>" />

Note: If you use any of the form helper functions listed in this page the form values will be prepped automatically, so there is no need to call this function. Use it only if you are creating your own form elements.


It is not really a question of better or performance it is more a question of what you really need to do with your form, and especially with dynamic data.

For example if you use :

<input type="text" name="username" value="<?php echo $username; ?>" />

To put a default or generated value from validation it is easier to do :

echo form_input('username', $username);

For example also using :

echo form_open('email/send');

Will generate the correct link / path to your controller so you don't have to worry about it if you move or change your application directory because it will put the correct value :

<form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send" />

And so on and so on ...