Welcome Guest, Not a member yet? Register   Sign In
Form Validation RUNS first time page is loaded
#1

[eluser]Ickes[/eluser]
Trying to do something a little different (and perhaps illogical) but it isn't working...

When loading this page, form validation automatically runs and errors out. As a result, my set_value never sets the initial value. Any ideas?

Code:
$this->form_validation->set_rules('title', 'Title', 'required|min_length[5]|max_length[70]|xss_clean');

if($this->form_validation->run() == TRUE)
{
  //YES, true - if success,
  //code to update database
}

//code for form_validation->run() == FALSE
$data['title'] = $this->sample_model->_get_title();

$this->load->view('title_view', $data);

And then the "title_view"
Code:
<?php
$title = array(
        'name'        =>    'title',
        'value'        =>    set_value('title', $title),
        'size'        =>    '70',
        'maxlength'    =>    '70'
    );
?>

<b>Title:</b><br />
&lt;?php echo form_input($title).'<br />'.form_error($title['name']);?&gt;

Any ideas? I editted out a lot of code so if you need more, please ask. I believe the necessary info is there.

The first time the page is loaded, I receive a message "The Title field is required." and the database value $title is never shown to the user.

Thanks.


Messages In This Thread
Form Validation RUNS first time page is loaded - by El Forum - 10-15-2009, 06:49 PM
Form Validation RUNS first time page is loaded - by El Forum - 10-15-2009, 07:47 PM
Form Validation RUNS first time page is loaded - by El Forum - 10-16-2009, 01:20 AM
Form Validation RUNS first time page is loaded - by El Forum - 10-22-2009, 12:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB