Welcome Guest, Not a member yet? Register   Sign In
Weird problem using arrays as field names and form validation
#1

[eluser]darytas[/eluser]
hey,

first, thanks for listning to my problem.
it is, kinda weird, but let me explain it.

I read much about using arrays as field names in CI and it seems like something experimental or just not working as intended. I found the solution with the custom MY_Validation and MY_Input (which is no longer needed as of 1.7.1 i read somewhere) - but in the end, it's not working like a charm.

The validation only works, if I - before the validation - access every single value of the folloing by the following line.

Code:
$this->input->post('smsform[sender]');

If I put this line, then "smsform[sender]" will validate.
But, I guess that's not the way it should work, am I right?

Code:
$this->validation->set_rules( array(
                                                'smsform[recipient]' => 'trim|css_clean|callback__checkrecipients',
                                                'smsform[phonebook]' => 'trim|css_clean',
                                                'smsform[sender]' => 'trim|required|css_clean',
                                                'smsform[status]' => 'trim|required|css_clean',
                                                'smsform[day]' => 'trim|required|css_clean|required|numeric|min_length[1]|max_length[2]',
                                                'smsform[month]' => 'trim|required|css_clean|numeric|min_length[1]|max_length[2]',
                                                'smsform[year]' => 'trim|required|css_clean|numeric|exact_length[4]',
                                                'smsform[hour]' => 'trim|required|css_clean|numeric|min_length[1]|max_length[2]',
                                                'smsform[minute]' => 'trim|required|css_clean|numeric|min_length[1]|max_length[2]',
                                                'smsform[text]' => 'trim|required|css_clean|min_length[1]',
                                                'smsform[gateway]' => 'trim|required|css_clean|numeric'
                                            )
                          

          );


Form is define like this:
Code:
<input type="text" name="smsform[recipient]" id="recipient-field" class="field  text large" value="<?= set_value(array('smsform', 'recipient'))?>" />


Problem
Form validation only works when I access every single value before the validation ran.


Any Ideas?
#2

[eluser]Thorpe Obazee[/eluser]
Try using the new Form Validation. I'm sure using arrays as field names work with the form validation class.
#3

[eluser]darytas[/eluser]
[quote author="bargainph" date="1245936060"]Try using the new Form Validation. I'm sure using arrays as field names work with the form validation class.[/quote]

Worked, thanks dude.




Theme © iAndrew 2016 - Forum software by © MyBB