Question

I am having a problem with Kohana 3.3. I cannot get the $_POST values using $this->request->post() on my Controller. I dont know what I did wrong on my code. Hope you can help me out here. BTW, I was able to use Twig on all my templates using Kohana 3.3 but I wasn't able to process the data from my forms. Thank you. :-)

Here is my code:

Controller:

class Controller_Setup extends Controller{
     public function action_item_group(){
         if (HTTP_Request::POST == $this->request->method()){
                // Post has no data
                print_r($this->request->post());

         }
         $this->response->body( Twig::factory('setup/sample_form') );
     }
}

View

<form class="form-horizontal" action="item_group" method="post" name="setup_form">
 <input type="text" value="">
 <button type="submit">Save</button>
</form>
Was it helpful?

Solution

You need to set name or id attributes to your HTML elements. Try this code and see if it's working now:

<form class="form-horizontal" action="item_group" method="post" name="setup_form">
 <input name="group_name" type="text" value="">
 <button type="submit">Save</button>
</form>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top