0

I have the follow code in my Controller, which is getting values from the dropbox chooser.

<?php class DropboxboxfilesController extends AppController {

  public function add() {
    if ($this->request->is('post')) {
        $this->request->input('json_decode');
        $this->Dropboxfile->create();
        if ($this->Dropboxfile->save($this->request->data)) {
            $this->Session->setFlash(__('Your file has been liberated :)'));
            $this->redirect($this->referer());
        } else {
            $this->Session->setFlash(__('Something went wrong!'));
        }
    }
}}?>

However, when I am getting the error that the add function does not exist when I hit submit on the submit button for the chooser.

I have tried several things but nothing seems to be working so far.

EDIT: View code

<?php echo $this->Form->create('Dropboxfile', array ('array' => 'file')); ?>
<input type="dropbox-chooser" name="selected-file" style="visibility: hidden;"/>  
<?php echo $this->Form->end('Finish'); ?>

The dropbox code I am using https://www.dropbox.com/developers/dropins/chooser/js

EDIT

<form action="/cake/homes" array="file" id="DropboxfileIndexForm" method="post" accept-    carset="utf-8"><div style="display:none;"><input type="hidden" name="_method" value="POST"/></div><input type="dropbox-chooser" name="selected-file" style="visibility: hidden;"/>  
<div class="submit"><input type="submit" value="Finish"/></div></form 
4

1 回答 1

0

您在 $this->Form->create() 中为第二个参数使用了错误的格式。请注意,在您解析的表单元素中,它有一个无效的 'array="file"' 元素,并且该操作不会导致添加操作。试试这个:

<?php 
echo $this->Form->create(
    'Dropboxfile', 
    array(
        'url' => array('action' => 'add'),
        'type' => 'file'
    )
);
?>
于 2013-07-19T18:09:30.813 回答