CakePHP saveMany 不保存

CakePHP saveMany doesnt save

我有以下表单代码。

<?php echo $this
   ->Form
   ->create(
       'PagePhoto',
       array(
           'type' => 'file',
           'url' => array(
                'controller' => 'page_photos',
                'action' => 'add'
            )
       )
  ); ?>
  <div class="modal-body has-padding">
       <div class="form-group">
       <?php echo $this->Form->label('PagePhoto.0.filename', 'Photos:'); ?>
       <br/><br/>
       <?php echo $this->Form->file('PagePhoto.0.filename', array('required' => false)); ?>
       <?php echo $this->Form->error('PagePhoto.0.filename', null, array('class' => 'label label-block label-danger text-left', 'wrap' => 'label')); ?>
       <br/>
       <?php echo $this->Form->file('PagePhoto.1.filename', array('required' => false)); ?>
       <?php echo $this->Form->error('PagePhoto.1.filename', null, array('class' => 'label label-block label-danger text-left', 'wrap' => 'label')); ?>
       <br/>
       <?php echo $this->Form->file('PagePhoto.2.filename', array('required' => false)); ?>
       <?php echo $this->Form->error('PagePhoto.2.filename', null, array('class' => 'label label-block label-danger text-left', 'wrap' => 'label')); ?>
       <br/>
       <?php echo $this->Form->file('PagePhoto.3.filename', array('required' => false)); ?>
       <?php echo $this->Form->error('PagePhoto.3.filename', null, array('class' => 'label label-block label-danger text-left', 'wrap' => 'label')); ?>
    </div>
  </div>
<div class="modal-footer">
     <button type="button" class="btn btn-warning" data-dismiss="modal">Close</button>
     <button type="submit" class="btn btn-primary">Upload Photos</button>
</div>

其中returns以下数组到add动作

array(
    'PagePhoto' => array(
        (int) 0 => array(
            'filename' => array(
                'name' => 'IMG_1683.jpg',
                'type' => 'image/jpeg',
                'tmp_name' => '/Applications/MAMP/tmp/php/phpoIrbZ6',
                'error' => (int) 0,
                'size' => (int) 94131
            )
        ),
        (int) 1 => array(
            'filename' => array(
                'name' => 'IMG_1683.jpg',
                'type' => 'image/jpeg',
                'tmp_name' => '/Applications/MAMP/tmp/php/phpAcbXbC',
                'error' => (int) 0,
                'size' => (int) 94131
            )
        ),
        (int) 2 => array(
            'filename' => array(
                'name' => 'IMG_1683.jpg',
                'type' => 'image/jpeg',
                'tmp_name' => '/Applications/MAMP/tmp/php/phppCeN8G',
                'error' => (int) 0,
                'size' => (int) 94131
            )
        ),
        (int) 3 => array(
            'filename' => array(
                'name' => 'IMG_1683.jpg',
                'type' => 'image/jpeg',
                'tmp_name' => '/Applications/MAMP/tmp/php/php8Ib3bO',
                'error' => (int) 0,
                'size' => (int) 94131
            )
        )
    )
)

添加操作

public function admin_add() {

        if ($this->request->is('post')) {
            debug($this->request->data);
            $this->PagePhoto->create();
            if ($this->PagePhoto->saveMany($this->request->data)) {
                $this->Session->setFlash(__('The gallery has been saved.'), 'admin/flash_success');
                // return $this->redirect(array('action' => 'view', $this->request->data['Gallery']['album_id']));
            } else {
                $this->Session->setFlash(__('The gallery could not be saved. Please, try again.'), 'admin/flash_error');
            }
        } else {
            // $this->request->data['Gallery']['album_id'] = $album_id;
        }
    }

错误:

FAILURE: The gallery could not be saved. Please, try again.

 $this->PagePhoto->saveMany($this->request->data['PagePhoto']);

注意:当保存同一模型的多个记录时,记录数组应该只是数字索引而没有模型键。