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. :-)
我遇到了Kohana 3.3的问题。我无法在Controller上使用$ this-> request-> post()获取$ _POST值。我不知道我在代码上做错了什么。希望你能在这里帮助我。顺便说一句,我能够使用Kohana 3.3在我的所有模板上使用Twig但是我无法处理来自表单的数据。谢谢。 :-)
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>
1 个解决方案
#1
5
You need to set name
or id
attributes to your HTML elements. Try this code and see if it's working now:
您需要为HTML元素设置name或id属性。试试这段代码,看看它现在是否正常工作:
<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>
#1
5
You need to set name
or id
attributes to your HTML elements. Try this code and see if it's working now:
您需要为HTML元素设置name或id属性。试试这段代码,看看它现在是否正常工作:
<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>