How to repopulate update form and radio inputs - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to repopulate update form and radio inputs (/showthread.php?tid=49759) |
How to repopulate update form and radio inputs - El Forum - 03-02-2012 [eluser]benners[/eluser] Can someone please point me in the right direction to re-populate the radio buttons on an update form. I think I need to utilize form validation but I've not been able to find enough information on this. Controller: Quiz Code: function update_test($comp_img) View: quiz_edit.php Code: echo form_open('quiz/save'); How to repopulate update form and radio inputs - El Forum - 03-02-2012 [eluser]Aken[/eluser] set_radio() takes a third parameter of TRUE/FALSE to set whether or not the radio item is checked. You'll need to addd some logic that fetches the value of your radio, sees if it's the same value as that particular radio, then sets that one to TRUE. How to repopulate update form and radio inputs - El Forum - 03-02-2012 [eluser]benners[/eluser] I'm struggling to get the set_radio TRUE of FALSE check to work correctly. I've abandoned the array for the following which isn't working either. Code: echo form_open('quiz/save'); How to repopulate update form and radio inputs - El Forum - 03-02-2012 [eluser]Aken[/eluser] Sorry, my mistake - the form_radio() function has the third parameter, not set_radio(). set_radio() will return a string - either empty if the radio should be checked, or 'checked="checked"' if it is. How to repopulate update form and radio inputs - El Forum - 03-02-2012 [eluser]porquero[/eluser] I set forms this: [controller] Code: $data = array( [view] Code: // Filed name Only you need change the $genre_selected variable and will checked correct radio. |