Reputation: 101
I am new in CakePHP
I have a form with code like this
$this->Form->create($ModelName, array("type"=>"file",'url' => array("controller"=>$ControllerName,"action"=>"CommitEdit", $ID,$page,$viewpage),'class' => 'form','novalidate'));
but when i submit the post, the controller doesnt have
$this->request->data //yield empty array
but it did have
$this->request->input() //multipart form body
also the action in controller resulting 403 Forbiden, even without any code inside the action
Edited
I tried to check, apparently, $_POST is also empty
Upvotes: 1
Views: 96
Reputation: 101
After digging around, i found the problem that when i use Form Helper with type "file", it create hidden field "_method" and then the value is "PUT", this make PHP can;t parse the multipart data, so i had to use normal tag,
or use type "POST" and put "enc-type=multipart/formdata" property manually
Upvotes: 0
Reputation: 448
try this simple method its work for you .
<?php
echo $this->Form->create('$ModelName',array("type"=>"POST","action"=>"CommitEdit",'class' => 'form' ,'novalidate'));
echo $this->Form->input('$ModelName.ID',array("type"=>"text","placeholder" => "ID"));
echo $this->Form->input('$ModelName.page',array("type"=>"file","placeholder" => "page"));
echo $this->Form->input('$ModelName.viewpage',array("type"=>"text","placeholder" => "viewpage"));
echo $this->Form->end(); ?>
Upvotes: 1