Welcome Guest, Not a member yet? Register   Sign In
Validation Errors, Okay, is it me or is this a bug?
#1

[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:
&lt;?php echo validation_errors(); ?&gt;
    &lt;form action="&lt;?=base_url()?&gt;seasons/new_season/&lt;?=$this-&gt;uri->segment(3)?&gt;" method="post" enctype="multipart/form-data">
    &lt;?php foreach($bg_color->result() as $id):?&gt;
        &lt;input type="hidden" id="id" name="league_id" value="&lt;?=$id-&gt;league_id?&gt;">
    &lt;?php endforeach;?&gt;
    &lt;input type="hidden" id="id" name="active" value="Y"&gt;
    &lt;input type="hidden" id="id" name="user_id" value="&lt;?echo getUserProperty('id');?&gt;"&gt;
        <fieldset>
            <legend>New Season</legend>

            <label for="series_id">Series</label>
            <select name="series_id">
            &lt;?php foreach($get_series->result() as $series) : ?&gt;
            <option value="&lt;?=$series->series_id?&gt;">&lt;?=$series->series_title?&gt;</option>
            &lt;?php endforeach;?&gt;
            </select><br />

            <label for="series_id">Car/Mod</label>
            <select name="car_name">
            &lt;?php foreach($get_cars->result() as $cars) : ?&gt;
            <option value="&lt;?=$cars->car_name?&gt;">&lt;?=$cars->car_name?&gt;</option>
            &lt;?php endforeach;?&gt;
            </select><br />

            <label for="title">Season Title</label>
            &lt;input type="text" class="field" name="season_title" value="" /&gt;&lt;br />

            <label for="slots">Max Available Slots</label>
            &lt;input type="text" class="field" name="slots" value="" /&gt;&lt;br />

            <label for="title">Charge Admission?</label>
            &lt;input type="radio" name="fee" value="N" checked&gt;No&lt;input type="radio" name="fee" value="Y"&gt;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>
            &lt;input type="text" class="field" name="entry_fee" value="0.00" /&gt;&lt;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>
            &lt;input type="radio" name="signup_open" value="N" checked&gt;No&lt;input type="radio" name="signup_open" value="Y"&gt;Yes<br />
            
                    &lt;input class="submit" type="submit" name="submit1" value="Submit" /&gt;
        </fieldset>
&lt;/form&gt;
#2

[eluser]srpurdy[/eluser]
okay I'm a dumbass. I need more coffee now. I had to move my page data stuff down into the if statement lol. embarrassing Smile




Theme © iAndrew 2016 - Forum software by © MyBB