Welcome Guest, Not a member yet? Register   Sign In
[newbie help]cant get form validation or re-population to work
#1

[eluser]zyddee[/eluser]
Hi!

I cant get the form validation to work..
It dosent post any validation errors nor re-populating the form,

what im doing wrong plz?

controller:
Code:
class Signup extends Controller {

    function __construct()
    {
        parent::Controller();
    }
    
    function index()
    {
            $this->load->helper('form');
            $this->load->library('form_validation');
          
            $this->template->write_view('content', 'welcome', $data);
            $this->template->write_view('content', 'signup', $data);


            $this->form_validation->set_rules('username', 'Username', 'required');
            $this->form_validation->set_rules('password', 'Password', 'required');
            $this->form_validation->set_rules('password2', 'Password Confirmation', 'required');
            $this->form_validation->set_rules('email', 'Email', 'required');

            if ($this->form_validation->run() == FALSE)
            {
                    $this->template->render();
            }
            else
            {
                    redirect('start');
            }
    }
}

view:
Code:
<?php echo validation_errors(); ?>

<?php echo form_open('signup'); ?>
    <table>
        <tr>
            <td>Your Name</td>
            <td>&lt;input type="text" value="&lt;?php echo set_value('name'); ?&gt;" id="name" name="name" /&gt;&lt;/td>
        </tr>
        <tr>
            <td>Username</td>
            <td>&lt;input type="text" value="&lt;?php echo set_value('username'); ?&gt;" id="username" name="username" /&gt;&lt;/td>
        </tr>
        <tr>
            <td>Password</td>
            <td>&lt;input type="password" value="&lt;?php echo set_value('password'); ?&gt;" id="password" name="password" /&gt;&lt;/td>
        </tr>
        <tr>
            <td>Confirm Password</td>
            <td>&lt;input type="password" value="&lt;?php echo set_value('password2'); ?&gt;" id="password2" name="password2" /&gt;&lt;/td>
        </tr>
        <tr>
            <td>E-mail</td>
            <td>&lt;input type="password" value="&lt;?php echo set_value('email'); ?&gt;" id="email" name="email" /&gt;&lt;/td>
        </tr>
        <tr>
            <td></td>
            <td>
                &lt;input type="submit" value="Submit Registration" /&gt;
            </td>
        </tr>
    </table>
&lt;/form&gt;

Best Regards!
#2

[eluser]zyddee[/eluser]
Ah nevermind..
its ofcourse because i dosent pass the validation variables to the template when loading the view data..
outcome after a long day and being tired -.-
#3

[eluser]cahva[/eluser]
I tested that(without using template lib) and it worked nicely. Comment out the template lines and just try to use the normal $this->load->view('signup'); and see if that makes a difference.. I really cant find anything else wrong there..
#4

[eluser]cahva[/eluser]
[quote author="zyddee" date="1265172160"]Ah nevermind..[/quote]
Too late Smile




Theme © iAndrew 2016 - Forum software by © MyBB