[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:
Code:
function add_boot()
{
if ($this->session->userdata('logged_in'))
{
$this->load->helper('assets');
$this->load->helper('form');
$this->load->helper('html');
$this->load->library('validation');
$this->load->model('CMS_model');
$this->load->model('Boot_model');
require('includes/navigation.php');
$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_rules($rules);
$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';
$this->validation->set_fields($fields);
if ($this->validation->run() == TRUE)
{
// get new bootID from database then go to cms/boot/$bootID
}
else
{
$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 <?=$content;?> tag in the middle of it.
Code:
<form acti>
<h4>Select Boot Type</h4>
<?=$this->validation->add_boot_type_error; ?>
<h5>Boot Type</h5><br />
<select name="add_boot_type" class="dropdown">
<option value=""></option>
<?php
foreach ( $type as $key => $value )
{ ?>
<option value="<?=$key;?>" <?=$this->validation->set_select('add_boot_type', $key);?> ><?=utf8_decode($value);?> </option>
<?php } ?>
</select>
<br /><br />
<h3>Choose Unique Boot Number and Name</h3>
<?=$this->validation->add_boot_nmbr_error;?>
<h5>Boot Number</h5><br />
<input name="add_boot_nmbr" class="login" type="text" size="12" maxlength="12" value="<?=$this->validation->add_boot_nmbr;?>" />
<?=$this->validation->add_boot_name_error; ?>
<h5>Boot Name</h5><br />
<input name="add_boot_name" class="login" type="text" size="12" maxlength="12" value="<?=$this->validation->add_boot_name;?>" />
<br />
<input name="add_boot" type="submit" value="Create New Boot" class="login"/>
</form>
Thanks for any and all help.