Form drop_down problem |
[eluser]Michal1[/eluser]
Hello guys I trying to use dropdowns in a simple way and I am having problems with them. I have a controller site and inside of function index I have: Code: $shirts_on_sale = array('small', 'large'); then in admin_view I have Code: <?php echo form_dropdown('shirts', $shirts_on_sale, 'large'); ?> But I receive an error Code: A PHP Error was encountered why is that? Thanks for any input
[eluser]danmontgomery[/eluser]
Code: $data = array('shirts_on_sale' => array('small', 'large'));
[eluser]Michal1[/eluser]
[quote author="noctrum" date="1312241160"] Code: $data = array('shirts_on_sale' => array('small', 'large')); Thank you but I dont understand why it has to be in this way?
[eluser]Michal1[/eluser]
Because even if I have this it does not work Code: $options = array( and then in admin_view: Code: <?php echo form_dropdown('shirts', $options, 'large'); ?>
[eluser]Aken[/eluser]
You need to read more about how dynamic data is passed to views: http://ellislab.com/codeigniter/user-gui...views.html
[eluser]Michal1[/eluser]
huh,I know how dynamic data are passed to views. I passed as an array of course here: Code: $this->load->view('admin_view',$options); So there must problem in a view in this line right? Code: <?php echo form_dropdown('shirts', $options, 'large'); ?>
[eluser]LuckyFella73[/eluser]
Quote:Because even if I have this it does not work Should look like: Code: $data['options'] = array( It's basically the same noctrum told you - I just tried to make it easier (visually) It's important for you to understand that you send an array to the view (in my example "$data") which keys are usable as variables/arrays in your view. Veery basic example: Code: // controller: Hope that makes it a bit clearer.
|
Welcome Guest, Not a member yet? Register Sign In |