Welcome Guest, Not a member yet? Register   Sign In
Forms - set_value driving me mad!
#1

[eluser]35mm[/eluser]
Creating login and register forms. The login form works fine and set_value works.

The registration form, set_value will not work and I've spent far to long trying to work out why! It will display the validation errors but not the set_value. If I enter a username and click submit, I get the validation error that no user name was entered. So it seems the username isn't even getting through to the controller. Saying that has just made me look at this in a different way - it's not set_value that isn't working. It's the whole form that isn't working! But why?

Here's the controller code (I've removed all but username validation to save space);
Code:
public function submit()
    {
      
            
            $this->load->helper(array('form', 'url'));
            $this->load->library('form_validation');
            
  $this->form_validation->set_rules('username', 'username', 'required');

  if ($this->form_validation->run() == FALSE)
  {
                    $this->config->load('config');
                    $site_name = $this->config->item('site_name');
                    $data=array('title'=>'Join ' . $site_name);
                    
                    $this->load->view('pages/register_form',$data);
  }
Then in the view I have this (relevant bits only;
Code:
echo form_open('register/submit');
    echo validation_errors();
    // user name
    $user_name = array(
              'name'        => 'username',
              'id'          => 'username',
              'maxlength'   => '25',
              'size'        => '25',
              'value'       => set_value('username'),
            );

    echo form_label('Username ', 'username') . form_input($user_name) . '<br />';


Messages In This Thread
Forms - set_value driving me mad! - by El Forum - 02-13-2013, 05:49 PM
Forms - set_value driving me mad! - by El Forum - 02-14-2013, 02:03 AM
Forms - set_value driving me mad! - by El Forum - 02-14-2013, 03:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB