# Mass Assignment Isn't working

**URL:** <https://discourse.cakephp.org/t/mass-assignment-isnt-working/3512>\
**Category:** Need Help\
**Created:** [November 17, 2017, 7:24pm UTC](https://discourse.cakephp.org/t/mass-assignment-isnt-working/3512 "2017-11-17T19:24:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gildonei](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/gildonei/32/844_2.png) [@gildonei](https://discourse.cakephp.org/u/gildonei)\
**Post date:** [November 17, 2017, 7:24pm UTC](https://discourse.cakephp.org/t/mass-assignment-isnt-working/3512/1 "2017-11-17T19:24:20Z")

</div>

Hi, trying to migrate from Cake 2 to 3 and I am not getting able to solve some doubts

I receive the data below from my form into my Controller

```
Array
(
    [Pessoas] => Array
        (
            [ds_nome] => Name Filled in Form
            [ds_imagem] => Array
                (
                    [tmp_name] => 
                    [error] => 4
                    [name] => 
                    [type] => 
                    [size] => 0
                )

            [fl_ativo] => 1
        )

    [Pessoafisicas] => Array
        (
            [nr_cpf] => 000.000.000-00
            [dt_nascimento] => 
            [sexo_id] => 1
            [estadocivil_id] => 
            [escolaridade_id] => 
            [ds_rg] => 
            [ds_orgao_expeditor] => 
            [dt_emissao_rg] => 
        )

    [Usuarios] => Array
        (
            [ds_login] => login
            [ds_senha] => pswd
            [ds_confirma_senha] => pswd
            [fl_ativo] => 1
        )

    [PerfisUsuarios] => Array
        (
            [2] => Array
                (
                    [perfil_id] => 2
                    [fl_ativo] => 1
                    [fl_padrao] => 0
                )

            [1] => Array
                (
                    [perfil_id] => 1
                    [fl_ativo] => 1
                    [fl_padrao] => 0
                )

        )

)
```

I have the following ModelTables

- **Pessoas**
- 
  - hasOne

- 
  - 
    - Pessoafisicas

- 
  - 
    - Usuarios

- 
  - hasMany

- 
  - 
    - PerfisUsuarios

- **Pessoafisicas**
- 
  - belongsTo

- 
  - 
    - Pessoas

- **Usuarios**
- 
  - belongsTo

- 
  - 
    - Pessoas

- 
  - hasMany

- 
  - 
    - PerfisUsuarios

- **Perfis**
- 
  - hasMany

- 
  - 
    - PerfisUsuarios

- **PerfisUsuarios**
- 
  - belongsTo

- 
  - 
    - Usuarios

- 
  - 
    - Perfis

And so a try to make the mass assignment of sent data

```
$pessoasTable = $this->loadModel('Pessoas');
$entityPessoa = $pessoasTable->patchEntities($pessoasTable, $this->request->getData(), [
    'associated' => [
        'Usuarios', 'Pessoafisicas', 'PerfisUsuarios'
    ]
]);
```

But it parses all the sent data into Pessoa Entity

```
Array
(
    [0] => App\Model\Entity\Pessoa Object
       (
            [ds_nome] => Name Filled in Form
            [ds_imagem] => 
 ...
    [1] => App\Model\Entity\Pessoa Object
            [nr_cpf] => 000.000.000-00
            [dt_nascimento] => 
 ...
)
```

Does anybody knows what Am I doing wrong?

Thank’s a lot

---

<div class="post-metadata">

**Author:** ![gildonei](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/gildonei/32/844_2.png) [@gildonei](https://discourse.cakephp.org/u/gildonei)\
**Post date:** [November 21, 2017, 7:10pm UTC](https://discourse.cakephp.org/t/mass-assignment-isnt-working/3512/2 "2017-11-21T19:10:26Z")

</div>

I found the problem about this Mass Assignment. The aliases used in Models (Tables) were in singular, while patch were in singular.
