cakephp - How to insert multiple entrys -
iam new cake , want set order process user send recommendations (friends mail adr) discount. each recommendation reduces price. want have 5 recommendation inserts in 1 step.
recommendation table (id, order_id, email)
i extend order model recommendations
class order extends appmodel { public $hasmany = array( 'recommendation' => array( 'classname' => 'recommendation', ) ); in order controller have use saveall method.
now, how should order add view like. if use
echo $this->form->input('recommendation.mail'); it save 1 recommendation, or ? have 5 of them on 1 page...
thank much, julius
change form this
echo $this->form->input('recommendation.0.mail'); echo $this->form->input('recommendation.1.mail'); echo $this->form->input('recommendation.2.mail'); echo $this->form->input('recommendation.3.mail'); echo $this->form->input('recommendation.4.mail'); then in controller,use saveall method
$this->recommendation->saveall($this->request->data);
Comments
Post a Comment