0
Я использую CakePHP 3.2 и плагин proffer для загрузки изображений.Загрузка нескольких изображений с использованием proffer в cakephp
У меня есть products
и product_images
таблица и использование одной формы для загрузки данных на две таблицы.
Это как моя форма
<?= $this->Form->create($product, ['type' => 'file') ?>
<?= $this->Form->input('title', ['required' => true]) ?>
<?= $this->Form->input('description', ['required' => true]) ?>
<?= $this->Form->input('product_images.0.image', ['required' => true, 'type' => 'file']) ?>
<?= $this->Form->input('product_images.1.image', ['type' => 'file']) ?>
<?= $this->Form->button('submit', ['type' => 'submit']) ?>
<?= $this->Form->end() ?>
и контроллер, как
public function add()
{
$product = $this->Products->newEntity();
if ($this->request->is('post')) {
$product = $this->Products->patchEntity($product, $this->request->data, [
'associated' => ['ProductImages']
]);
if ($this->Products->save($product)) {
$this->Flash->success('Product saved');
}
}
}
Но это сохранение данных в таблице продуктов, а не к изображениям продукта.