Welcome Guest, Not a member yet? Register   Sign In
What's Wrong Here?

[eluser]charlie spider[/eluser]
Ever have a problem right in front of your eyes but you just don't see it ?

The problem:

validation errors the instant my form is loaded for the VERY FIRST TIME !!!

Can't figure out what i'm overlooking.

Here's the controller:

function add_boot()
    if ($this->session->userdata('logged_in'))
        $data['status'] = $this->load->view('modules/status', $data, TRUE);
        $data['menu'] = $this->load->view('modules/menu', $data, TRUE);
        $data['page'] = 'add_boots';
        $data['pageInfo'] = array('pageName' => 'Add New Boot');
        $data['error_msg'] = "";
        $data['type'] = $this->Boot_model->get_boot_types(0);
        $data['java'] = '';                
        $data['keywords'] = '';
        $data['metadesc'] = '';
        $rules['add_boot_type'] = "required";
        $rules['add_boot_nmbr'] = "trim|required|min_length[2]|max_length[12]";
        $rules['add_boot_name'] = "trim|required|min_length[4]|max_length[24]";
        $this->validation->set_error_delimiters('<div class="error">', '</div>');
        $fields['add_boot_type']    = 'Boot Type';
        $fields['add_boot_nmbr']    = 'Boot Number';
        $fields['add_boot_name']    = 'Boot Name';
        if ($this->validation->run() == TRUE)    
            // get new bootID from database then go to cms/boot/$bootID
            $data['content'] = $this->load->view('modules/cms_add_boot', $data, TRUE);            
            $this->load->view('modules/cms_view', $data);
    else {  redirect('cms', 'refresh'); }

and here's the 'modules/cms_add_boot' view:

note: 'modules/cms_view' is a generic container view that all of my content gets loaded into. It's basically all of the header, navigation and footer stuff for the page with a &lt;?=$content;?&gt; tag in the middle of it.

&lt;form acti&gt;
<h4>Select Boot Type</h4>
&lt;?=$this->validation->add_boot_type_error; ?&gt;
<h5>Boot Type</h5><br />

<select name="add_boot_type" class="dropdown">
<option value=""></option>
foreach ( $type as $key => $value )
{ ?&gt;
<option value="&lt;?=$key;?&gt;" &lt;?=$this->validation->set_select('add_boot_type', $key);?&gt; >&lt;?=utf8_decode($value);?&gt;&nbsp;&nbsp;&nbsp;</option>
&lt;?php } ?&gt;
<br /><br />

<h3>Choose Unique Boot Number and Name</h3>

<h5>Boot Number</h5><br />
&lt;input name="add_boot_nmbr" class="login" type="text" size="12" maxlength="12" value="&lt;?=$this-&gt;validation->add_boot_nmbr;?&gt;" />

&lt;?=$this->validation->add_boot_name_error; ?&gt;
<h5>Boot Name</h5><br />
&lt;input name="add_boot_name" class="login" type="text" size="12" maxlength="12" value="&lt;?=$this-&gt;validation->add_boot_name;?&gt;" />
<br />
&lt;input name="add_boot" type="submit" value="Create New Boot" class="login"/&gt;

Thanks for any and all help.

Is error it gives is as if the form has already been submitted?

What does the output of this look like the first time?

[eluser]Armchair Samurai[/eluser]
Sounds like you've got $_POST data being submitted to the page: does the user navigate to add_boot through a form submission?

[eluser]charlie spider[/eluser]
Armchair Samurai - you win the prize.

i used a "Add New Boot" button to get to the page. Didn't know that would trigger the validation. I will change it to a regular link.

ontguy - you get the consolation prize for helping out.

Thanks guys! very appreciated

Theme © iAndrew 2016 - Forum software by © MyBB