[eluser]Dan Tdr[/eluser]
Hello,
I have a dilemma, i searched over the web as much as i could (it`s almost 2am so maybe i missed the answer, though i dought it).
I`m trying to make my controllers as readable as possible for other programmers and me
I have a controller that has $lang as a parameter and this code:
Code:
$this->form_validation->set_rules('service_name'.$lang, 'Nume', 'required|min_length[3]|max_length[20]|xss_clean|callback_paginaNume');
$this->form_validation->set_rules('service_url'.$lang, 'URL', 'required|xss_clean');
$this->form_validation->set_rules('service_content'.$lang, 'Continut', 'required');
$this->form_validation->set_rules('service_description'.$lang, 'Descriere [META]', 'required|min_length[10]|max_length[160]|xss_clean');
$this->form_validation->set_rules('service_keywords'.$lang, 'Cuvinte Cheie [META]', 'required|min_length[10]|max_length[160]|xss_clean');
$this->form_validation->set_rules('service_robots', 'Robots [META]', 'required');
$this->form_validation->set_rules('service_visible', 'Vizibila', 'required');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
this works well for me, but i want to add all this info to an array in form_validation.php. Is there any way i could transmit the variable $lang to the form_validation.php file?
so that this code would work?
form_validation.php content below
Code:
$config = array(
'admin/add_servicii' => array(
array(
'field' => 'username'[b].$lang[/b],
'label' => 'Username',
'rules' => 'required'
),
array(
'field' => 'password',
'label' => 'Password',
'rules' => 'required'
),
array(
'field' => 'passconf',
'label' => 'PasswordConfirmation',
'rules' => 'required'
),
array(
'field' => 'email',
'label' => 'Email',
'rules' => 'required'
)
),
);
Note: the $config variable is taken from the CI userguide and does not really matter, all that matters is the $lang variable.
For example i could insert in my database from the link example.com/adduser/ro the field usernamero, from the link example.com/adduser/en the field usernameen. Keep in mind that the languages could be just 2 or 10, and writing the validation rules in all the languages would be of no use.
Thank you very much,
Dan