在cakephp中一次提交中插入多行
在这件事上我真的需要帮助。我想允许用户以单眉多上传 视图如下所示:在cakephp中一次提交中插入多行,cakephp,cakephp-2.3,Cakephp,Cakephp 2.3,在这件事上我真的需要帮助。我想允许用户以单眉多上传 视图如下所示: <?php echo $this->Form->create('TypologyPicture', array('type'=>'file')); ?> <legend><?php echo __('Add Picture'); ?></legend> <?php echo $this->Form->inp
<?php echo $this->Form->create('TypologyPicture', array('type'=>'file')); ?>
<legend><?php echo __('Add Picture'); ?></legend>
<?php
echo $this->Form->input('id');
echo $this->Form->input('typology_id');
echo $this->Form->input('pic_path', array('label'=>'Picture','type'=>'file','multiple'=>'multiple'));
?>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
/**
* add method
*
* @return void
*/
public function add() {
if ($this->request->is('post')) {
$this->TypologyPicture->create();
if ($this->TypologyPicture->save($this->request->data)) {
$this->Session->setFlash(__('The typology picture has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The typology picture could not be saved. Please, try again.'));
}
}
if ( AuthComponent::user('role')==='admin' ||AuthComponent::user('role')==='superadmin' ){
$typologies = $this->TypologyPicture->ItemTypologyPicture->find('list');
} else {
$typologies = $this->TypologyPicture->ItemTypologyPicture->find('list', array('conditions' => array('ItemTypologyPicture.user_id' => AuthComponent::user('id'))));
}
$this->set(compact('typologies'));
}
所以我想实现的是,当用户点击浏览时,他可以选择多张图片,也可以选择这张图片所属的类型。因此,当他点击提交所有选择的phottos上传,并属于他刚才选择的类型。那么,如何只需一次提交就可以将所有图像路径保存在db中
Thanx这在CakePHP书中关于的章节中有非常清楚的解释,特别是关于Thanx的部分,我将看一看