I leave Codeigter beacause I love Flurish Features but I can't migrate my code from my previous Apps to Flourish
This is my Controller. I set a few rules after this I run the validation if it fails it loads the view and show the errors otherwise it insert the user into de database and redirect to other controller.
public function insert() {
$this->form_validation->set_rules('firstname', 'Nombre', 'required|trim');
$this->form_validation->set_rules('lastname', 'Apellidos', 'required|trim');
$this->form_validation->set_rules('email', 'Correo Electrnico', 'required|trim|valid_email');
$this->form_validation->set_rules('password', 'Contrasea', 'required|trim|sha1');
if ( $this->form_validation->run() ) {
$user->firstname = $this->input->post('firstname');
$user->lastname = $this->input->post('lastname');
$user->email = $this->input->post('email');
$user->password = $this->input->post('password');
$user->created = now();
$user->modified = now();
$this->users->insert($user);
redirect('authentication/');
} else {
$data->view = 'user/insert';
$this->load->view('store/index', $data);
}
}
View
#!text/html
<?php echo form_open('user/insert', array('class' => 'basic')); ?>
<div class="inner-form">
<?php if ( validation_errors() != '' ) : ?>
<div class="msg msg-error"><?php echo validation_errors(); ?></div>
<?php endif; ?>
<dl>
<dt><?php echo form_label('Nombre', 'firstname'); ?></dt>
<dd>
<?php
$input = array(
'name' => 'firstname',
'class' => 'txt',
'value' => set_value('firstname')
);
echo form_input($input);
?>
</dd>
<dt><?php echo form_label('Apellidos', 'lastname'); ?></dt>
<dd>
<?php
$input = array(
'name' => 'lastname',
'class' => 'txt',
'value' => set_value('lastname')
);
echo form_input($input);
?>
</dd>
<dt><?php echo form_label('Correo Electrnico', 'email'); ?></dt>
<dd>
<?php
$input = array(
'name' => 'email',
'class' => 'txt',
'value' => set_value('email')
);
echo form_input($input);
?>
</dd>
<dt><?php echo form_label('Contrasea', 'password'); ?></dt>
<dd>
<?php
$input = array(
'name' => 'password',
'class' => 'txt pwd'
);
echo form_password($input);
?>
</dd>
</dl>
</div>
<?php echo form_close(); ?>
I think that I should use isPost() method but I don't know how to merge fValidation and the exceptions to my previous code.