Open koffisani opened 6 years ago
Please can you expand your question with more information? Where have you configured the behavior?
Thanks, I have the following :
class EvenementsTable extends Table {
public function initialize(array $config)
{
$this->hasMany('Valeurevents', [
'foreignKey' => 'evenement_id'
]);
}
}
and
class ValeureventsTable extends Table {
public function initialize(array $config)
{
$this->belongsTo('Evenements', [
'foreignKey' => 'evenement_id',
'joinType' => 'INNER'
]);
$this->addBehavior('Proffer.Proffer', [
'fichier' => [
'root' => WWW_ROOT . 'uploads',
'dir' => 'fichier_dir',
],
]);
}
}
The valeurevents
table's tructure is the following :
valeurevents | type |
---|---|
content | varchar(255) |
evenement_id | int |
fichier | varchar(255) |
fichier_dir | varchar(255) |
And now I'm trying to upload the file from EvenementsContoller
, what doesn't work.
Perhaps you need to save the associations as well?
You can read more about this in the book. https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-hasmany-associations
I'm trying to upload a file in related table's controller, but it doesn't work. Can somebody help me make this work ?