Welcome Guest, Not a member yet? Register   Sign In
validation_errors() not displaying anything
#1

[eluser]Unknown[/eluser]
My validation_errors() function is not displaying anything. Not sure what I am doing wrong.

This is my controller (login.php)
Code:
include "home.php";

class Login extends CI_Controller {
    
    public function __construct() {
        parent::__construct();
        
        $this->home = new Home();
    }
    
    function index() {
        $this->home->site['main_content'] = 'login_form';
        $this->load->view('template', $this->home->site);        
    }
    
    function signup() {
        $this->home->site['main_content'] = 'signup_form';
        $this->load->view('template', $this->home->site);
    }
    
    function create_member() {
        $this->form_validation->set_rules('firstname', 'First Name', 'trim|required|min_length[2]|max_length[12]|xss_clean');
        $this->form_validation->set_rules('lastname', 'Last Name', 'trim|max_length[12]|xss_clean');
        $this->form_validation->set_rules('email_address', 'Email Address', 'trim|required|valid_email|xss_clean');
        $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[4]|xss_clean');
        $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_length[32]');
        $this->form_validation->set_rules('password2', 'Password Confirmation', 'trim|required|matches[password]');
        
        
        if($this->form_validation->run() == FALSE) {
            $this->home->site['main_content'] = 'signup_form';
            $this->load->view('template', $this->home->site);
        }
        
        else {            
            /////
        }
        
    }
}

This is my view- main template (template.php)
Code:
<html>
<head></head>
<body>
       <div id="sidebar1">
            &lt;?php $this->load->view('includes/menu1_view'); ?&gt;
    </div>

        <div id="mainContent">
            &lt;?php
                if (isset($main_content) && $main_content == "signup_form"):
                    $this->load->view('includes/signup_view');
                endif;
            ?&gt;
        </div>
&lt;/body&gt;
&lt;/html&gt;

This is another view called from template.php (signup_view.php). validation_errors() does not display anything here.
Code:
&lt;?php
    echo validation_errors();  // NOTHING DISPLAYED!
    echo form_open('login/create_member');
?&gt;

<fieldset>
    <legend>Personal Info</legend>
    &lt;?php

        echo form_error('firstname');
        echo form_input('firstname', set_value('firstname', 'First Name'));
        echo form_input('lastname', set_value('lastname', 'Last Name'));
        echo form_input('email_address', set_value('email_address', 'Email Address'));
    ?&gt;
</fieldset>

<fieldset>
    <legend>Login Info</legend>
    &lt;?php
        echo form_input('username', set_value('username', 'Username'));
        echo form_password('password', set_value('password', 'Password'));
        echo form_password('password2', 'Password Confirm');
        
        echo form_submit('submit', 'Create Acccount');
    ?&gt;
</fieldset>




Theme © iAndrew 2016 - Forum software by © MyBB