Welcome Guest, Not a member yet? Register   Sign In
populating a form from DB
#5

[eluser]Colin Williams[/eluser]
I think set_value() is a fairly useless function, especially when using a form view that is either populated with submitted results or populated with default values. $_POST is already a key => value data structure, and what you return from your model is likely a key => value structure as well. Given that, consider this kind of code in an edit function:

Code:
$form['values'] = get_blog_post_array($id);
if (count($_POST))
{
  $form['values'] = $this->input->xss_clean($_POST);
}

Then in your view, you access values via $values['key']:

Code:
<input type="text" value="<?php print form_prep($values['title']) ?>" name="title" />
<textarea name="body"><?php print htmlspecialchars($values['body']) ?></textarea>

You can also do some more general sanitizing in your controller if you wish (like form_prep(), etc).


Messages In This Thread
populating a form from DB - by El Forum - 08-17-2009, 08:28 AM
populating a form from DB - by El Forum - 08-17-2009, 08:35 AM
populating a form from DB - by El Forum - 08-17-2009, 10:20 AM
populating a form from DB - by El Forum - 08-18-2009, 02:12 AM
populating a form from DB - by El Forum - 08-18-2009, 02:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB