[eluser]Deep Arora[/eluser]
Here's what I am doing:
In my controller:
Code:
$options = array(
'small' => 'Small Shirt',
'med' => 'Medium Shirt',
'large' => 'Large Shirt',
'xlarge' => 'Extra Large Shirt'
);
$form_field_category = "category|Link Category|dropdown|small|" . $options;
$view_fields = array(form_field_category);
create_form($view_fields, 'form_path', 'form_name', 'perm_add');
So, I have created an array of values to be set for a dropdown form field in controller. Then I call create_form function from helper.
Inside this function:
Code:
$form_field = explode("|", $value);
if ($form_field[4]): $field_value = $form_field[4];
else : $field_value = set_value($form_field[0]);
endif;
since I have passed the VALUE field (as $options) from my controller, the form_field[4] should now have that array.
Then while I generate the form field in the same function as;
Code:
$my_form = $my_form . "<div>". form_dropdown($form_field[4], $form_field[4]);
..it gives an error
Code:
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: helpers/form_helper.php
Line Number: 310
I tried printing the array in form_filed[4] and all it prints is the word ARRAY.
What could be wrong?