[eluser]Khoa[/eluser]
Hi,
First, I really love this new validation, and probably many people do as well. But I'm encountering a small problem that I don't know how to achieve with this new library.
The application/config /form_validation.php can now store all validations at one place as everyone knows. But I can only do that with functions without arguments, it they do have arguments, how can I put them here as well?
For example, this works fine:
Code:
$config = array(
// Register new user
'register/index' =>
array(
array(
'field' => 'email',
'label' => 'email',
'rules' => 'required|max_length[255]|valid_email|callback_email_check|trim'
)
)
)
because inside the controller, the function is declared as:
Code:
class Register extends Controller
{
function index()
{
...
}
}
But if the function is declared as:
Code:
class Register extends Controller
{
function FUNC($arg1, $arg2)
{
...
}
}
it cannot be used inside the form_validation.php file above. I tried the followings but none of them works:
Code:
$config = array(
// Register new user
'register/FUNC($arg1, $arg2)' =>
array(
array(
'field' => 'email',
'label' => 'email',
'rules' => 'required|max_length[255]|valid_email|callback_email_check|trim'
)
)
)
OR
Code:
$config = array(
// Register new user
'register/FUNC/(:num)/(:any)' =>
array(
array(
'field' => 'email',
'label' => 'email',
'rules' => 'required|max_length[255]|valid_email|callback_email_check|trim'
)
)
)
OR
Code:
$config = array(
// Register new user
'register/FUNC/(:any)' =>
array(
array(
'field' => 'email',
'label' => 'email',
'rules' => 'required|max_length[255]|valid_email|callback_email_check|trim'
)
)
)
What I mean by doesn't work is it just simply skips the validation. I think that's because the 'register/index' matches the function index inside register controller, but none of what I tried matches the function FUNC($arg1, $arg2).
Does anyone know if we can do this with the library?
Thanks,
Khoa