I have a problem with the saveAll function. There are two models,
Property and Images:
Property HasMany Image
Image belongTo Property
Also I have this form:
------------------------------------------------------------------------------
<div class="properties form">
<?php echo $form->create('Property', array('type' => 'file'));?>
<fieldset>
<legend><?php __('Add Property');?></legend>
<?php
echo $form->input('Property.title');
echo $form->input('Property.descrizione');
echo $form->input('Property.prezzo');
echo $form->input('Property.metratura');
echo $form->input('Property.affitto');
echo $form->input('Property.zones_id');
echo $form->input('Property.types_id');
echo $form->input('Image.0.nomeFile');
echo $form->input('Image.1.nomeFile');
?>
</fieldset>
<?php echo $form->end('Salva'); ?>
</div>
-------------------------------------------------------------------------------
and this is the action method in my controller:
------------------------------------------------------------------------------
function add() {
if (!empty($this->data)) {
$this->Property->create();
if ($this->Property->saveAll($this->data, array
('validate'=>'first')) {
$this->Session->setFlash(__('The Property has
been saved', true));
$this->redirect(array('action'=>'add'));
} else {
$this->Session->setFlash(__('The Property could
not be saved.
Please, try again.', true));
}
}
$zones = $this->Property->Zone->find('list');
$types = $this->Property->Type->find('list');
$this->set(compact('zones', 'types'));
}
------------------------------------------------------------------------------
Now the result is that the Property model is saved but the related
model Image is not saved. Why? I have checked the array sintax and it
is correct, also i've checked the Model Fields and they are correct.
Can someone help me? Thak you...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---