Hi,
I'm trying to use David Person's Media Plugin with an hasMany association
and it doesn't work...
My environment:
- Win XP
- CakePHP 1.3.14
- PHP 5.3.8
- Media Plugin 1.3
Media plugin is in my App/plugins directory.
In my config/boostrap.php, I have: "require
APP.'plugins/media/config/core.php"
I've created a model called "Attachment", with a database table
"attachmentes" defined like that:
ID
model
foreign_key
dirname
basename
checksum
alternative
group
created
modified
In Attachement Model, I've defined the behavior like that:
public $actsAs = array('Media.Transfer','Media.Coupler').
In a Apartment Model, I've defined an hasMany association like that:
public $hasMany = array('Photo' => array(
'className' => 'Media.Attachment',
'foreignKey' => 'foreign_key',
'dependent' => true,
'conditions' => array('Photo.model' => 'Apartment'),
));
In a Apartment edit view I've my form defined like that:
<?php echo
$this->Form->create('Apartment',array('type'=>'file','action'=>'edit_photos'));
?>
<?php echo $this->Form->input('Apartment.id'); ?>
<?php echo
$this->Form->hidden('Attachment.0.model',array('value'=>'Apartment')); ?>
<?php echo $this->Form->end(__('Save',true)); ?>
And finally, in my edit_photos method, I make a saveAll() like that:
$this->Apartment->saveAll($this->data, array('validate' => 'first'));
When I submit a valid file (a real jpg image), the saveAll return true, but
no file is uploaded in "webroot/media/transfer/img" directory and there is
no record saved in my "attachments" table...
I've tried to define an belongsTo association with Apartment in Attachment
model, no success.
I've tried to just using "Media.Tranfer", no success.
What I miss?!
thanks by advance for any help.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php