03-18-2011, 03:25 PM
[eluser]Konfine[/eluser]
[quote author="froginvasion" date="1300477572"]I'm trying to use both functions in one, as it would make it easier than just writing plain HTML tags. The code that causes me trouble is this one:
It should repopulate the checkboxes at validation, but it only sets back one of them, and never more than one. But I don't know why...[/quote]
It does work, I've used it in many applications.
One of the main problems that new starters aren't aware of is that you should include every form item in your form validation file. If you have a config file thats good but it'll also work using the set rules part. You can simply add trim or xssclean which ensures your form data is captured once submitted.
When creating form elements I always use the array function as I almost always use ID's for use with JS, consider the following:
[quote author="froginvasion" date="1300477572"]I'm trying to use both functions in one, as it would make it easier than just writing plain HTML tags. The code that causes me trouble is this one:
Code:
<fieldset>
<legend>locaties</legend>
<?php echo form_checkbox('locatie','oudenaarde', set_checkbox('locatie','oudenaarde'));?>3-7-2011 te Oudenaarde <br />
<?php echo form_checkbox('locatie','arendonk', set_checkbox('locatie','arendonk'));?>31-7-2011 Arendonk<br />
<?php echo form_checkbox('locatie','westdonk', set_checkbox('locatie','westdonk'));?>11-09-2011 Westhoek – MERKEN<br />
</fieldset>
It should repopulate the checkboxes at validation, but it only sets back one of them, and never more than one. But I don't know why...[/quote]
It does work, I've used it in many applications.
One of the main problems that new starters aren't aware of is that you should include every form item in your form validation file. If you have a config file thats good but it'll also work using the set rules part. You can simply add trim or xssclean which ensures your form data is captured once submitted.
When creating form elements I always use the array function as I almost always use ID's for use with JS, consider the following:
Code:
<?php $data = array('id' => 'locatie', 'name' => 'locatie', 'value' => 'oudenaarde', 'checked' => set_checkbox('locatie', 'oudenaarde', FALSE)); ?>
<?php echo form_checkbox($data); ?>