• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
repopulating select multiple form element

I'm having a hard time trying to figure out how to repopulate a select multiple form field if I find errors and I'm redirected back to the page with the form. How exactly do I grab all the values that were in the select field? I know once I recieve the post data, I can just foreach through it, but it seems that codeigniter does not work like this for post back data. Any help is much appreciated and this is my current code:
<select id='root_cause' name='root_cause' multiple="multiple">
    foreach($root_causes AS $rc) {
        ?&gt;<option value="&lt;?=$rc->id;?&gt;"
        &lt;?php if(validation_errors()) {
                  foreach(set_value('root_cause') AS $id) {
                      if(set_value('root_cause') == $rc->id) {
                          echo " SELECTED";
              } ?&gt;>&lt;?=$rc->cause;?&gt;</option>&lt;?php

Yes I did post something similar to this before, but my problem was never solved, just completely sidetracked.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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