Fix form validation to use config file

This commit is contained in:
Eike Foken
2011-08-11 12:53:26 +02:00
parent 075b7ba643
commit 9917711154
2 changed files with 47 additions and 2 deletions

View File

@@ -0,0 +1,45 @@
<?php defined('BASEPATH') || exit("No direct script access allowed");
$config = array(
'users' => array(
array(
'field' => 'username',
'label' => _('Username'),
'rules' => 'trim|required|min_length[4]|max_length[20]|unique[users.username]',
),
array(
'field' => 'password',
'label' => _('Password'),
'rules' => 'required|min_length[6]|matches[password_confirm]',
),
array(
'field' => 'password_confirm',
'label' => _('Confirm password'),
),
array(
'field' => 'firstname',
'label' => _('First name'),
'rules' => 'trim|required|max_length[50]',
),
array(
'field' => 'lastname',
'label' => _('Last name'),
'rules' => 'trim|required|max_length[50]',
),
array(
'field' => 'email',
'label' => _('Email address'),
'rules' => 'trim|required|valid_email',
),
array(
'field' => 'institution',
'label' => _('Institution'),
'rules' => 'trim|max_length[100]',
),
array(
'field' => 'phone',
'label' => _('Phone number'),
'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]',
)
)
);

View File

@@ -10,8 +10,8 @@ class MY_Form_validation extends CI_Form_validation {
/**
* Calls the parent constructor.
*/
public function __construct() {
parent::__construct();
public function __construct($rules = array()) {
parent::__construct($rules);
// overwrite default error delimiters
$this->set_error_delimiters('<p class="error">', '</p>');