Welcome Guest, Not a member yet? Register   Sign In
Form drop_down problem
#9

[eluser]LuckyFella73[/eluser]
Quote:Because even if I have this it does not work

$options = array(
'small' => 'Small Shirt',
'med' => 'Medium Shirt',
'large' => 'Large Shirt',
'xlarge' => 'Extra Large Shirt',
);
$this->load->view('admin_view',$options);
and then in admin_view:

<?php echo form_dropdown('shirts', $options, 'large'); ?>

Should look like:
Code:
$data['options'] = array(
    'small'  => 'Small Shirt',
    'med'    => 'Medium Shirt',
    'large'   => 'Large Shirt',
    'xlarge' => 'Extra Large Shirt'
    );
$this->load->view('admin_view',$data);
//and then in admin_view:

echo form_dropdown('shirts', $options, 'large');

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:
$data['variable_1'] = 'Value 1';
$data['variable_2'] = 'Value 2';
$data['test_array'] = array(0 => 'array value 1', 1 => 'array value 2');
$this->load->view('admin_view',$data);

//view file:
echo $variable_1;
echo $variable_2;
foreach ($test_array ...)
// do something

Hope that makes it a bit clearer.


Messages In This Thread
Form drop_down problem - by El Forum - 08-01-2011, 12:14 PM
Form drop_down problem - by El Forum - 08-01-2011, 12:23 PM
Form drop_down problem - by El Forum - 08-01-2011, 12:26 PM
Form drop_down problem - by El Forum - 08-01-2011, 12:27 PM
Form drop_down problem - by El Forum - 08-01-2011, 12:30 PM
Form drop_down problem - by El Forum - 08-01-2011, 02:44 PM
Form drop_down problem - by El Forum - 08-01-2011, 05:56 PM
Form drop_down problem - by El Forum - 08-02-2011, 12:21 AM
Form drop_down problem - by El Forum - 08-02-2011, 03:48 AM
Form drop_down problem - by El Forum - 08-02-2011, 03:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB