0
J'essaie d'enregistrer plusieurs enregistrements dans une seule table. Mais face à un problème lors de l'enregistrement des données de formulaire. Le problème peut être avec les éléments de formulaire. S'il vous plaît aidez-moi à ce sujetComment enregistrer plusieurs enregistrements dans cakephp 3.4.12
Controller méthode save
$data = $this->request->data();
$stockin = TableRegistry::get('Stockin');
$entities= $stockin->newEntities($data);
$stockin->saveMany($entities);
Formulaire
echo $this->Form->input("stockin.$i.date", [ 'value' => $stockindate]);
echo $this->Form->input("stockin.$i.product_id", [ 'value' => $prod->id]);
echo $this->Form->input("stockin.$i.quantity", ['label' => false]);
echo $this->Form->input("stockin.$i.harvested", ['options' =>
$harvested,'label' => false]);
echo $this->Form->input("stockin.$i.price", [ 'label' => false]);
Poster valeur de tableau est
[
'stockin' => [
(int) 0 => [
'date' => '2017-08-18',
'product_id' => '3',
'quantity' => '1',
'harvested' => 'k',
'price' => '1212'
],
(int) 1 => [
'date' => '2017-08-18',
'product_id' => '2',
'quantity' => '2112',
'harvested' => 'k',
'price' => '12312'
],
(int) 2 => [
'date' => '2017-08-18',
'product_id' => '1',
'quantity' => '12',
'harvested' => 'k',
'price' => '12'
]
]
]