[eluser]RobertSF[/eluser]
I'm using an array for my form fields. I've set validation rules according to the manual, and both form_error() and set_value() are working as expected. However, after I submit the form and run the validation successfully, I'm having trouble retrieving the values through the Input class.
When I execute this code:
Code:
if ($this->form_validation->run())
{
var_dump($this->input->post());
var_dump($this->input->post('glist'));
var_dump($this->input->post('glist[name]'));
exit;
I get this result:
Code:
array
'glist' =>
array
'name' => string 'Motorcycle Club' (length=15)
'gifts' => string '3' (length=1)
'price' => string '2.50' (length=4)
'submit' => string 'Ok' (length=2)
array
'name' => string 'Motorcycle Club' (length=15)
'gifts' => string '3' (length=1)
'price' => string '2.50' (length=4)
boolean false
That is to say, I can retrieve the entire post array, and I can retrieve an array in the post array, but I can't seem retrieve elements from an array in the post array. I've tried various combinations like,
Code:
var_dump($this->input->post('glist['name']'));
var_dump($this->input->post("glist['name']"));
var_dump($this->input->post("glist[name]"));
var_dump($this->input->post('glist[\'name\']'));
but they all return false.
What is the correct way to retrieve array elements from the post array through the Input class?