I am a 3+ years old in cakephp and facing a somewhat strange issue with submitting a form to plugin controller's action (i am using plugin first time). After trying different known things i am posting this one.
Going straight into the matter here is the form in my "forum" plugin's search_controller.php's "index" view:
echo $form->create("Search", array('url'=>array('controller' =>
'search', 'action' => 'index','plugin'=>'forum'),
'id'=>'searchFormMain'));
<input type="text" name="data[Search][keyword]" style="width:357px; margin-left:9px;"><p><span id="searchButton"><input
type="image" src="/img/button_search.jpg" style="height:40px;width:
136px;border:0;" class="handcursor"></span></p>
</form>
As i am submitting this form to "index" action of search controller of forum plugin, the following code does print nothing:
public function index($type='') {
if(!empty($this->data)) {
pr($this->data);
die;
}
}
While if i try the same code within beforeFilter of the same controller i.e. search_controller.php it works well and prints as follows:
Array
(
[Search] => Array
(
[keyword] => Hello Forum
)
)
And finally here is the beforeFilter code (of search_controller.php):
public function beforeFilter() {
parent::beforeFilter();
if(!empty($this->data)) {
pr($this->data);
}
}
Fyi, it does not matter if i comment out "parent::beforeFilter();" or even disable $uses of my controller (if they look doubtful to you) the result is same i.e. the control is not going in to "index" action in the case of form submit while is working fine in the case of page call. The url/action to page is http://localhost.rfdf.org/forum/search/index. If i call the url directly it loads the form fine but when i submit it, it never gets into the "index" action of the controller thus no view rendered.
If i try the same set of code out of "forum" plugin environment i.e. in normal application it works just fine
I have been trying to find a way out of this for last 3+ hours now but no success. I would appreciate any help in solving this puzzle.