• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
form_checkbox and set_checkbox

#7
[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:

Code:
<fieldset>
    <legend>locaties</legend>
    &lt;?php echo form_checkbox('locatie','oudenaarde', set_checkbox('locatie','oudenaarde'));?&gt;3-7-2011 te Oudenaarde <br />
    &lt;?php echo form_checkbox('locatie','arendonk', set_checkbox('locatie','arendonk'));?&gt;31-7-2011 Arendonk<br />
    &lt;?php echo form_checkbox('locatie','westdonk', set_checkbox('locatie','westdonk'));?&gt;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:
&lt;?php $data = array('id' => 'locatie', 'name' => 'locatie', 'value' => 'oudenaarde', 'checked' => set_checkbox('locatie', 'oudenaarde', FALSE)); ?&gt;

&lt;?php echo form_checkbox($data); ?&gt;


Messages In This Thread
form_checkbox and set_checkbox - by El Forum - 03-18-2011, 08:46 AM
form_checkbox and set_checkbox - by El Forum - 03-18-2011, 09:27 AM
form_checkbox and set_checkbox - by El Forum - 03-18-2011, 10:17 AM
form_checkbox and set_checkbox - by El Forum - 03-18-2011, 10:41 AM
form_checkbox and set_checkbox - by El Forum - 03-18-2011, 11:02 AM
form_checkbox and set_checkbox - by El Forum - 03-18-2011, 03:17 PM
form_checkbox and set_checkbox - by El Forum - 03-18-2011, 03:25 PM
form_checkbox and set_checkbox - by El Forum - 03-18-2011, 07:13 PM
form_checkbox and set_checkbox - by El Forum - 03-21-2011, 03:21 PM
form_checkbox and set_checkbox - by El Forum - 09-04-2012, 02:10 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.