Reputation: 9297
I need help on how to use the form_dropdown in Codeginiter project.
View file: my_test.php code as this,
<?php
// basic filter form
$attributes = array('class' => 'formstyle', 'id' => 'myfilterform');
echo form_open('mytest/send', $attributes);
$options = array(
'all' => 'Pls Select Filter',
'male' => 'Male List',
'female' => 'Female List',
);
echo form_dropdown('myfilter', $options, 'male');
echo form_submit('myfiltersubmit', ' GO ');
$string = "</div></div>";
echo form_close($string);
?>
Controllers file mytest.php code as this,
function index()
{
$data['title'] = "Hello";
$this->load->view('my_test', $data);
}
function send()
{
$mypostdata = $_POST['options']; // I can't get the post data here.
echo $mypostdata;
}
I did read the form_dropdown portion on CI UserGuide. unfortunately I didn't find how to handle post data in send()
. Thanks.
Upvotes: 0
Views: 12663
Reputation: 90746
To get the dropdown's selected value, you need to get $_POST['myfilter'] (assuming "myfilter" is the name of your dropdown)
In general, to debug POST data, you might want to do a "var_dump($_POST)" That will show you all the POST data and help you figure out how to retrieve each value.
Upvotes: 3