Hi, so I have a Tarif, which hasMany Price (each for different currency - doesn't really matter)
the view (deleted irrelevant parts)
<?php echo $this->Form->create('Tarif');
echo $this->Form->input("Price.0.price");
echo $this->Form->input("Price.0.currency");
echo $this->Form->input("Price.0.sms_format");
echo $this->Form->input("Price.0.sms_number");
echo $html->link(__('Add currency', true), '#', array('onclick'=>'return false;', 'class' => 'tarifs-add-currency'));
echo $this->Form->input('Tarif.valid_since', array('timeFormat' => '24'));
echo $this->Form->input('Tarif.valid_until', array('timeFormat' => '24'));
echo $this->Form->input('Tarif.storage_time', array('label' => __('Storage time (days)', true)));
echo $this->Form->end(__('Submit', true));?>
The controller function to save it looks like this
function admin_add() {
if (!empty($this->data)) {
$this->Tarif->create();
if ($this->Tarif->saveAll($this->data)) {
$this->Session->setFlash(__('The tarif has been saved', true));
$this->redirect(array('action' => 'admin_index'));
} else {
$this->Session->setFlash(__('The tarif could not be saved. Please, try again.', true));
}
}
}
The "add currency" link is there to add new inputs for new prices, but that isn't the problem, because it doesn't work even without adding currencies. When I try to save it, it says 'The tarif could not be saved. Please, try again.'. Don't you know what should I change in order to make it work?
Thanks EL