Welcome Guest, Not a member yet? Register   Sign In
Benefit of form helper?
#1

[eluser]Shpigford[/eluser]
I'm curious...what's the real benefit of the form helper?

Like what's the benefit of typing this:
Code:
form_hidden('username', 'johndoe');
Rather than this:
Code:
<input type="hidden" name="username" value="johnodoe" />

Sure it's a tad shorter...but is that the only real difference?
#2

[eluser]Pascal Kriete[/eluser]
I'm pretty sure the answer is: yes, that's the only difference.

I've found it convenient to have the ability to just pass in an array, especially when more than one value has to change.

What it comes down to is that anything you can do with a helper, you can implement yourself with a little more code. I suppose that's why they're called helpers Wink.
#3

[eluser]Michael Wales[/eluser]
I only use the form_open and form_close() functions myself - this way the form action is always correct. Plus, in future versions of CI - using these two functions will automatically enable cross-site forgery protection (from Expression Engine).
#4

[eluser]Craig A Rodway[/eluser]
I think it's useful to be able to pass an array of names/values to a function to create form controls; for example when in a loop, re-populating from validation and anywhere else you need a bit of PHP to change something.

But it's all down to what works for you - if you don't like it - don't use it Smile
#5

[eluser]Seppo[/eluser]
I think it will be useful if it "evolves" in a class and works with validation/upload... for instance, if you set a form_dropdown, CI can check that the submitted value is a possible key for the options array.
#6

[eluser]Derek Allard[/eluser]
Agreed on all counts! Right now, the benefits are few, as the form helper is really just a fancy string generator. But by using it now we allow for growth and tighter integration with other components (as they come).




Theme © iAndrew 2016 - Forum software by © MyBB