Ich benutze Kuchen 2.0.6 und ich versuche, mehrere Datensätze zu speichern, die Produkte sind meine Datenausgabe aus dem Formular ist unten;Saveall funktioniert nicht
Ich kann es nicht erhalten, um die zwei Datensätze zu speichern, die Felder in meinem Formular sind wie festgelegt; wobei 0 der erste Datensatz ist, den es speichern sollte. Es speichert nicht die 2 Datensätze aus irgendeinem Grund. Ich habe alle Validierung für das Produktmodell deaktiviert und habe keine befortsave-Methode
Irgendwelche Ideen was ist falsch?
<input name="data[Product][0][product_code]"/>
<input name="data[Product][0][colour]"/>
<input name="data[Product][0][lead_time_weeks]"/>
<input name="data[Product][0][description]"/>
<input name="data[Product][0][height]" />
<input name="data[Product][0][width]" />
<input name="data[Product][0][depth]" />
<input name="data[Product][0][price]" />
<input name="data[Product][0][discount]" />
<input name="data[Product][0][discounted_price]" />
<input name="data[Product][0][quantity]"/>
<input name="data[Product][1][product_code]"/>
<input name="data[Product][1][colour]"/>
<input name="data[Product][1][lead_time_weeks]"/>
<input name="data[Product][1][description]"/>
<input name="data[Product][1][height]" />
<input name="data[Product][1][width]" />
<input name="data[Product][1][depth]" />
<input name="data[Product][1][price]" />
<input name="data[Product][1][discount]" />
<input name="data[Product][1][discounted_price]" />
<input name="data[Product][1][quantity]"/>
Array
(
[Product] => Array
(
[0] => Array
(
[product_code] => fgfgf
[colour] =>
[lead_time_weeks] =>
[description] =>
[height] => 11111
[width] => 22222
[depth] =>
[price] =>
[discount] => 50
[discounted_price] =>
[quantity] =>
)
[1] => Array
(
[product_code] => fgfgf
[colour] =>
[lead_time_weeks] =>
[description] =>
[height] => 123
[width] => 123
[depth] =>
[price] =>
[discount] => 50
[discounted_price] =>
[quantity] =>
)
)
)
EDIT: Lösung für die Zukunft; Rufen Sie die Speichermethode wie folgt auf;
$ this-> Produkte-> SaveAll ($ this-> request-> data [ 'Produkt']
ich nenne es so; $ this-> Produkt-> saveAll ($ this-> request-> data); ild versuchen Sie Ihre Lösung. –
danke dafür dachte ich, ich habe alles im Buch ausprobiert aber das hat funktioniert: $ this-> Produkt-> saveAll ($ this-> request-> data ['Product'] –