[eluser]srpurdy[/eluser]
Form Validation errors.
I been pulling my hair out of this one, for the life of me I can't understand why it's doing this.
I can do a print_r(validation_errors()); in my controller This will work! I can do an echo also and it works, but if I do eiher of these two in my view file I get a blank string! How is that possible.... The only thing I can think of is that data isn't being passed to my view file, yet the validation rules are working no problem. So This is confusing.
I've read a lot of topics on here with people having the same issue and I haven't seen them solved at all.
Example of my code below only the parts that matter
Code:
$this->load->library('form_validation');
$this->form_validation->set_message('required', 'Not all required fields were filled in, please try again.');
$this->form_validation->set_message('alpha_numeric', 'The Season Title Can only be Alpha Numeric Format, please try again.');
$this->form_validation->set_message('decimal', 'The Entry Fee field can only be an integet with two leading integers, and two following decimal places.');
$this->form_validation->set_message('numeric', 'The Slots field can only be a number, please try again.');
$this->form_validation->set_rules('user_id', 'user_id', 'xss_clean|required');
$this->form_validation->set_rules('season_title', 'season_title', 'xss_clean|required|alpha_numeric');
$this->form_validation->set_rules('slots', 'slots', 'xss_clean|required|numeric');
$this->form_validation->set_rules('entry_fee', 'entry_fee', 'xss_clean|required|decimal');
$data['heading'] = "New Season";
$league_temp2 = $this->leagues_model->get_league_temp2();
$data['page'] = $this->config->item('FAL_template_dir'). $league_temp2. '/new_season';
$league_temp = $this->leagues_model->get_league_temp();
$this->_container = $this->config->item('FAL_template_dir'). $league_temp;
$this->load->vars($data);
$this->load->view($this->_container);
$this->form_validation->set_error_delimiters('<h5>', '</h5>');
if($this->form_validation->run() == FALSE)
{
//print_r(validation_errors());
//$msg = $this->lang->line('FAL_sp_required_fields');
//flashMsg($msg);
}
View File
Code:
<?php echo validation_errors(); ?>
<form action="<?=base_url()?>seasons/new_season/<?=$this->uri->segment(3)?>" method="post" enctype="multipart/form-data">
<?php foreach($bg_color->result() as $id):?>
<input type="hidden" id="id" name="league_id" value="<?=$id->league_id?>">
<?php endforeach;?>
<input type="hidden" id="id" name="active" value="Y">
<input type="hidden" id="id" name="user_id" value="<?echo getUserProperty('id');?>">
<fieldset>
<legend>New Season</legend>
<label for="series_id">Series</label>
<select name="series_id">
<?php foreach($get_series->result() as $series) : ?>
<option value="<?=$series->series_id?>"><?=$series->series_title?></option>
<?php endforeach;?>
</select><br />
<label for="series_id">Car/Mod</label>
<select name="car_name">
<?php foreach($get_cars->result() as $cars) : ?>
<option value="<?=$cars->car_name?>"><?=$cars->car_name?></option>
<?php endforeach;?>
</select><br />
<label for="title">Season Title</label>
<input type="text" class="field" name="season_title" value="" /><br />
<label for="slots">Max Available Slots</label>
<input type="text" class="field" name="slots" value="" /><br />
<label for="title">Charge Admission?</label>
<input type="radio" name="fee" value="N" checked>No<input type="radio" name="fee" value="Y">Yes - <span style="color:#ff0000">You will need a paypal business account to use this feature.</span><br /><br />
<label for="slots">Entry Fee</label>
<input type="text" class="field" name="entry_fee" value="0.00" /><span style="color:#ff0000">Enter the amount in dollars you wish to charge for admission, without the $ sign.</span><br /><br />
<label for="title">Signups Open?</label>
<input type="radio" name="signup_open" value="N" checked>No<input type="radio" name="signup_open" value="Y">Yes<br />
<input class="submit" type="submit" name="submit1" value="Submit" />
</fieldset>
</form>