Welcome Guest, Not a member yet? Register   Sign In
Prepopulating radio input
#1

[eluser]Bramme[/eluser]
Okay, I'm having a weird problem. Dunno where to go look for the solution though.

I'm building an edit form that has several inputs: textboxes, textareas, some checkboxes and a set of radio inputs.

Now I want to prepopulate the edit form, which works great for the text bits, but I can't get the radio buttons to prepopulate.

Code:
if( empty($this->validation->error_string)) {
    foreach ($fields as $field => $name) {
        $this->validation->$field = $data['tut'][$field];
    }
}
That's the code I use in my controller, it simply puts the values from the DB in if validation hasn't run yet.

Now I've changed the set_radio thingie (which doesn't work with prepopulated data, as it only looks at $_POST and not at $this->validation) with my own if:

Code:
<input type="radio" name="rankID" value="<?=$rank['rankID']?>" id="rank-<?=$rank['rankID']?>" <?php if($select_rank == $rank['rankID']) echo 'selected="selected" '; ?>/>

Now this works, I can see the selected="selected" code in my source code, it changes correctly when you submit the form but validation fails etc.

HOWEVER: it doesn't get selected in the form in the browser itself. Has anybody got any idea what could be causing this?


Messages In This Thread
Prepopulating radio input - by El Forum - 09-12-2008, 03:22 AM
Prepopulating radio input - by El Forum - 09-12-2008, 03:43 AM
Prepopulating radio input - by El Forum - 09-12-2008, 03:48 AM
Prepopulating radio input - by El Forum - 09-12-2008, 03:58 AM
Prepopulating radio input - by El Forum - 09-12-2008, 04:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB