Welcome Guest, Not a member yet? Register   Sign In
FormIgniter.org launched - Easy form generator - source code now available
#18

[eluser]Ollie Rattue[/eluser]
[quote author="ururk" date="1254792480"]Nice tool!

One question - why are you not using form helper for all elements, eg:

Code:
<input id="test" type="text" name="test" value="<?php echo set_value('test'); ?>
vs

Code:
$data = array(
              'name'        => 'test',
              'id'          => 'test',
              'value'       => 'test'
            );

echo form_input($data);

I realize it is more code this way... but in some ways this makes the code reusable.

John[/quote]

Thanks for you useful feedback. I have not included the form helper for all the form elements, because I simply don't find it useful. A helper is meant to 'help' you write less code, however for a text input the code above is as long.

A example of a very useful form helper is for Selects, where an array can be passed for the options, and the select option can be easily repopulated. Writting this in html would take significantly longer.

Code:
<?php $options = array(
                      ''  => 'Please Select',
                      'example_value1' => 'example option 1'
                      'example_value2' => 'example option 2'
                      ); ?>

<br />&lt;?=form_dropdown('test', $options, set_value('test'))?&gt;

Another issue that prevents me from using html/form helpers, is that they tend to confuse frontend html/css developers. A frontend developer is able to work their way through html with the small bits of php code, but when it is all replaced with arrays and helpers of an unknown framework, it can often get confusing. It has then again ceased to add any benefit.

Finally it doesn't actually matter if the non-helper version is longer (which I don't think it is) as the writting of this code is automated by FormIgniter.

An option could be added to FormIgniter to output html or use the codeigniter helpers, but I think the time/gain ratio for this is low.

Opinionated software Smile


Messages In This Thread
FormIgniter.org launched - Easy form generator - source code now available - by El Forum - 10-06-2009, 03:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB