Welcome Guest, Not a member yet? Register   Sign In
Filling form variables
#1

[eluser]jwburnside[/eluser]
Hey everyone.

I was wondering about best practices for filling in form data that might come from either a database or from post data (or neither), specifically concerning empty form variables, which throw an error:

A simplified version that I have been doing is this:


Code:
//View
<li>&lt;?= form_label('Nickname', 'nickname', array('class' => '')); ?&gt;
    &lt;?= form_input(array('id' => 'nickname', 'name' => 'nickname', 'size' => 60, 'value' => set_value('nickname',$nickname))); ?&gt;
      </li>

Code:
//Controller
if(!isset($_POST['form_return'])) {

  if($row)
     $view_data = array(...the database data);
  else
     $view_data = array(...Here is where I have to define empty form variables);
}

else
  $view_data = $_POST

It works fine, but I would rather not have to set empty variables for the form should there be no database or $_POST data. How is this best accomplished with Codeigniter?

Any help would be appreciated.


Messages In This Thread
Filling form variables - by El Forum - 12-06-2010, 10:13 AM
Filling form variables - by El Forum - 03-11-2011, 04:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB