[eluser]zenonn[/eluser]
Getting Undefined property: CI_Validation:: errors. I upgraded to 1.6.2 and my forms are having all types of validation problems.
The code:
Thanks in advance.
<?php
class Customer extends Controller
{
function __construct(){
parent::Controller();
$this->load->model('quote_model');
}
function index()
{
$head['title'] = "Customer Online Quote";
$this->load->helper(array('form', 'url'));
$this->load->library('validation');
$rules['fname'] = "required|max_length[40]";
$rules['lname'] = "required|max_length[40]";
$rules['email'] = "required|max_length[40]|valid_email";
$this->validation->set_error_delimiters('<div class="error">', '</div>');
$this->validation->set_rules($rules);
$fields['fname'] = 'First Name';
$fields['lname'] = 'Last Name';
$fields['email'] = 'Email Address';
$this->validation->set_fields($fields);
$data['fname'] = $this->input->post('fname');
$data['lname'] = $this->input->post('lname');
$data['email'] = $this->input->post('email');
$data['generator'] = $this->input->post('quote');
$data['code'] = rand(10000,500000);
$data['call'] = $this->input->post('mail');
if ($this->validation->run() == FALSE)
{
$this->load->view('cquote',$head);
}
else
{ $this->quote_model->save_data($data);
redirect('customer/success');
}
}
The Form
<?=form_label('First Name:*','First Name');?>
<input type="text" name="fname" value="<?=$this->validation->fname;?>"/>
<?=$this->validation->fname_error;?>
</li>
<li>
<?=form_label('Last Name:*','Last Name');?>
<input type="text" name="lname" value="<?=$this->validation->lname;?>"/>
<?=$this->validation->lname_error;?>
</li>
<li>
<?=form_label('Email:*','Email');?>
<input type="text" name="email" value="<?=$this->validation->email;?>"/>
<?=$this->validation->email_error;?>
</li>
</ol>
</fieldset>
<fieldset>
<legend>Quote</legend>
<ol>
<li>
<?=form_label('Generators:','Generators');?>
<select name="quote">
<option value="8kw" selected="selected">8,000 Watts</option>
<option value="10kw">10,000 Watts</option>
<option value="14kw">14,000 Watts</option>
<option value="17kw">17,000 Watts</option>
<option value="20kw">20,000 Watts</option>
</select>
</li>
<li>
Would you like a follow up email?</li>
<li><?=form_label('Please Select:','Please Select');?>
<select name="mail">
<option value="No" selected="selected">No</option>
<option value="Yes">Yes</option>
</select>
</li>
</ol>
</fieldset>
<fieldset class="submit">
<input type="submit" name="submit" value="submit" class="submit"/>
</fieldset>
<?=form_close();?>