title: association data is not saved in cakephp 3.6
body: <p>I want to save data in multiple tables using association in cakephp 3.6. I have two tables departments and users. 
  Relationship is </p>
  
  <ul>
  <li>Departments hasMany users</li>
  <li>Users belongTo Departments</li>
  </ul>
  
  <p>here is my code</p>
  
  <h1>DepartmentsController</h1>
  
  <pre><code>&lt;?php
  namespace App\Controller;
  use App\Controller\AppController;
  use Cake\Event\Event;
  class DepartmentsController extends AppController
  {
      public function register()
      {
          $this-&gt;loadModel('Departments');
          $department = $this-&gt;Departments-&gt;newEntity();
          if ($this-&gt;request-&gt;is('post')) {
              $department = $this-&gt;Departments-&gt;patchEntity($department, $this-&gt;request-&gt;data, [
                  'associated' =&gt; [
                      'Users'
                  ]
              ]);
              if ($this-&gt;Departments-&gt;save($department)){
                  $resultJ = json_encode(['status' =&gt; true, 'result' =&gt; 'You are registered and can login']);
              } 
              else {
                  $resultJ = json_encode(['status' =&gt; false, 'result' =&gt; 'Something went wrong! Please try again']);
              }
              $this-&gt;response-&gt;type('json');
              $this-&gt;response-&gt;body($resultJ);
              return $this-&gt;response;
  
          }
          $this-&gt;set(compact('department', 'user'));
          $this-&gt;set('_serialize', ['department']);
          $this-&gt;viewBuilder()-&gt;setLayout('login');
      }
  }
  </code></pre>
  
  <h1>register.ctp</h1>
  
  <pre><code>&lt;?php
  $this-&gt;Form-&gt;setTemplates([
      'inputContainer' =&gt; '{{content}}'
  ]);
  echo $this-&gt;Form-&gt;create($department, ['class' =&gt; 'registration-form']);
  ?&gt;
      &lt;div class="alert alert-danger display-hide"&gt;
          &lt;button class="close" data-close="alert"&gt;&lt;/button&gt;
          &lt;span&gt;&lt;?= __('Please fill the required fields.') ?&gt; &lt;/span&gt;
      &lt;/div&gt;
      &lt;?= $this-&gt;Flash-&gt;render() ?&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-xs-12 col-md-6"&gt;
              &lt;?= $this-&gt;Form-&gt;control('users.0.first_name', [
                  'label' =&gt; false, 
                  'class' =&gt; 'form-control form-control-solid placeholder-no-fix form-group',
                  'placeholder' =&gt; __('First Name'),
                  'autocomplete' =&gt; 'off',
              ]); ?&gt;
          &lt;/div&gt;
          &lt;div class="col-xs-12 col-md-6"&gt;
              &lt;?= $this-&gt;Form-&gt;control('users.0.last_name', [
                  'label' =&gt; false, 
                  'class' =&gt; 'form-control form-control-solid placeholder-no-fix form-group',
                  'placeholder' =&gt; __('Last Name'),
                  'autocomplete' =&gt; 'off',
              ]); ?&gt;
          &lt;/div&gt;
          &lt;div class="col-xs-12 col-md-6"&gt;
              &lt;?= $this-&gt;Form-&gt;control('users.0.email', [
                  'label' =&gt; false, 
                  'class' =&gt; 'form-control form-control-solid placeholder-no-fix form-group',
                  'placeholder' =&gt; __('E-mail'),
                  'autocomplete' =&gt; 'off',
              ]); ?&gt;
          &lt;/div&gt;
          &lt;div class="col-xs-12 col-md-6"&gt;
              &lt;?= $this-&gt;Form-&gt;control('users.0.password', [
                  'label' =&gt; false, 
                  'class' =&gt; 'form-control form-control-solid placeholder-no-fix form-group',
                  'placeholder' =&gt; __('Password'),
                  'autocomplete' =&gt; 'off',
                  'type' =&gt; 'password'
              ]); ?&gt;
          &lt;/div&gt;
          &lt;div class="col-xs-12 col-md-6"&gt;
              &lt;?= $this-&gt;Form-&gt;control('name', [
                  'label' =&gt; false,
                  'id' =&gt; 'domain_name',
                  'class' =&gt; 'form-control form-control-solid placeholder-no-fix form-group',
                  'placeholder' =&gt; __('Department Name'),
                  'autocomplete' =&gt; 'off',
              ]); ?&gt;
          &lt;/div&gt;
          &lt;div class="col-xs-12 col-md-6"&gt;
              &lt;?= $this-&gt;Form-&gt;control('domain', [
                  'label' =&gt; false, 
                  'id' =&gt; 'domain_slug',
                  'class' =&gt; 'form-control form-control-solid placeholder-no-fix form-group',
                  'placeholder' =&gt; __('Domain Name'),
                  'autocomplete' =&gt; 'off',
              ]); ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-sm-4"&gt;
              &lt;div class="forgot-password-link"&gt;
                  &lt;?= $this-&gt;Html-&gt;link(__('Already have an account?'), '/', ['class' =&gt; 'forget-password', 'id' =&gt; 'forget-password']) ?&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="col-sm-8 text-right"&gt;
              &lt;?= $this-&gt;Form-&gt;button(__('Sign Up'), ['class' =&gt; 'btn blue']) ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;?= $this-&gt;Form-&gt;end() ?&gt;
  </code></pre>
  
  <h1>DepartmentsTable.php</h1>
  
  <pre><code>&lt;?php
  namespace App\Model\Table;
  
  use Cake\ORM\Query;
  use Cake\ORM\RulesChecker;
  use Cake\ORM\Table;
  use Cake\Validation\Validator;
  class DepartmentsTable extends Table
  {
      public function initialize(array $config)
      {
          parent::initialize($config);
  
          $this-&gt;setTable('departments');
          $this-&gt;setDisplayField('name');
          $this-&gt;setPrimaryKey('id');
  
          $this-&gt;addBehavior('Timestamp');
          $this-&gt;hasMany('Users', [
              'foreignKey' =&gt; 'department_id'
          ]);
      }
  
      public function validationDefault(Validator $validator)
      {
          $validator
              -&gt;uuid('id')
              -&gt;allowEmpty('id', 'create');
  
          $validator
              -&gt;scalar('org_no')
              -&gt;maxLength('org_no', 35)
              -&gt;allowEmpty('org_no');
  
          $validator
              -&gt;boolean('active')
              -&gt;requirePresence('active', 'create')
              -&gt;notEmpty('active');
  
          return $validator;
      }
  
      public function buildRules(RulesChecker $rules)
      {
          $rules-&gt;add($rules-&gt;existsIn(['department_id'], 'Users'));
          return $rules;
      }
  }
  </code></pre>
  
  <h1>UsersTable.php</h1>
  
  <pre><code>&lt;?php
  namespace App\Model\Table;
  
  use Cake\ORM\Query;
  use Cake\ORM\RulesChecker;
  use Cake\ORM\Table;
  use Cake\Validation\Validator;
  class UsersTable extends Table
  {
      public function initialize(array $config)
      {
          parent::initialize($config);
  
          $this-&gt;setTable('users');
          $this-&gt;setDisplayField('id');
          $this-&gt;setPrimaryKey('id');
  
          $this-&gt;addBehavior('Timestamp');
  
          $this-&gt;belongsTo('Departments', [
              'foreignKey' =&gt; 'department_id',
          ]);
      }
     public function validationDefault(Validator $validator)
      {
          $validator
              -&gt;uuid('id')
              -&gt;allowEmpty('id', 'create');
          return $validator;
      }
  
  
      public function buildRules(RulesChecker $rules)
      {
          $rules-&gt;add($rules-&gt;isUnique(['email']));
          return $rules;
      }
  }
  </code></pre>
  
  <h1>Entity Model</h1>
  
  <h1>Department.php</h1>
  
  <pre><code>&lt;?php
  namespace App\Model\Entity;
  
  use Cake\ORM\Entity;
  
  class Department extends Entity
  {
      protected $_accessible = [
          'name' =&gt; true,
          'org_no' =&gt; true,
          'domain' =&gt; true,
          'active' =&gt; true,
          'created' =&gt; true,
          'modified' =&gt; true,
          'user' =&gt; true
      ];
  }
  </code></pre>
  
  <p>The problem is data only save into departments table not in users table. How can I save data in users table using cakephp 3.6 associations?</p>