input->get('var_name') |
[eluser]ELRafael[/eluser]
Hy Guys, My view. It's a simple search form current_url() = http://site.local/news/index Code: <?php echo form_open( current_url(), 'method="get"' ); ?> My Controller (news, function index()) Code: $search_term = $this->input->get('search_term'); Result: Always bool(false) The url "submited" http://site.local/news/index?ci_csrf_tok...Acentuação&..... My config.php Code: $config['uri_protocol'] = "AUTO"; I'm using CodeIgniter 2.0 under MAMP enviroment Can anyone help me? Before any anwser, I know if I change the form's method to post and try to get the value using $this->input->post('search_term') will work fine. But I really wanna use GET method, not POST. I still belive that POST method is for CHANGING ACTIONS (new user, edit data, ....) Thanks a lot
[eluser]CroNiX[/eluser]
Haven't messed with it, but you might want to try setting: $config['enable_query_strings'] = TRUE; $config['uri_protocol'] = "QUERY_STRING";
[eluser]ELRafael[/eluser]
Still no donut for me :blank: Code: $config['enable_query_strings'] = TRUE; Now the problem is another!! When I open the page, and I can't submit anymore. Click in the submit button and come back to main page (base_url()). I just wanna use $this->input->get('var_name') :down: I'm starting to think that CI can't work with query strings
[eluser]Eric Barnes[/eluser]
I think you want this using ci2 reactor: Code: $config['allow_get_array'] = TRUE;
[eluser]ELRafael[/eluser]
Eric, still don't work. config.php Code: //allow_get_array is in the TOP of file My form Code: <?php echo form_open(current_url(), 'method="get"'); ?> http://site.local/news/index?ci_csrf_tok...xto=asdasd&.... My controller Code: var_dump($this->input->get('search_term')); I'm not using CodeIgniter Reactor. I just did the download from codeigniter.com I'll try to implement a Javascript (JQuery) solution. Code: $('form#my_form_id').submit(function(e) { I still don't know why $this->input->get('var_name') returns false all the time.
[eluser]Eric Barnes[/eluser]
Try it manually: http://yousite.com/controller/method?searchterm=test Then in controller: Code: var_dump($this->input->get('searchterm'));
[eluser]abedzilla[/eluser]
You must enable query string and set the uri_protocol to PATH_INFO Code: $config['uri_protocol'] = "PATH_INFO"; |
Welcome Guest, Not a member yet? Register Sign In |