Insert multiple select field with associated model

Hello guys. I’m having trouble inserting values ​​into two different tables. If I use multiple select, there is no insertion in the database. If I leave the select without being multiple there is insertion in the database. Any suggestion?

BeforeMarshal with multiple select false:

BeforeMarshal with multiple select true:

Total speculation here, but my first instinct would be to check the models. Have you ruled that out yet? (Multiple select requires belongsToMany be properly set up and that validation and rules are in agreement)

class SisadDemandSectorInvolvedsTable extends Table
{
public function initialize(array $config)
{
$this->belongsToMany(‘SisadDemands’, [
‘foreignKey’ => ‘sisad_demand_id’,
]);
}
}

and…

class SisadDemandsTable extends Table
{
public function initialize(array $config)
{
$this->hasMany(‘SisadDemandSectorInvolveds’, [
‘foreignKey’ => ‘sisad_demand_id’,
‘joinType’ => ‘INNER’
]);
}
}

For multiple selections, you need to use the _ids field.

you already got it? I have no idea how to do it

As a first attempt, try replacing sisad_demand_sector_involveds.sector_id in your form with sisad_demand_sector_involveds._ids, and see how the entity looks after patching.

I tried and it still didn’t work.