title: CAKEPHP 3: Argument 1 passed to Cake\ORM\Table::patchEntity() must implement interface Cake\Datasource\EntityInterface, boolean given
body: <p><strong>Thank you for your support</strong></p>
  <p>I'm working on a project for a survey system with every questionnaire having multiple questions and in other to make adding questions i'm using Jquery to load multiple field set for all the question to be added and save at the same time Instead of adding it one after the other</p>
  <p>but i'm having Issues with my code as it shows this error</p>
  <p><strong>Argument 1 passed to Cake\ORM\Table::patchEntity() must implement interface Cake\Datasource\EntityInterface, boolean given, called in C:\wamp64\www\surveynaija\src\Controller\QuestionnairesController.php on line 65</strong></p>
  <p>The line 65 refers to <code>$result = $questions-&gt;patchEntity($result, $this-&gt;request-&gt;getData());</code></p>
  <p><strong>here is the controller code</strong></p>
  <pre><code>public function addquestions(){
      $data[] = [
              'question' =&gt; 'question',
              'questionnaire_id' =&gt; 'questionnaire_id',
              'questiontype_id' =&gt; 'questiontype_id'
      ] ;
      $questions = TableRegistry::getTableLocator()-&gt;get('Questions');
      $entities = $questions-&gt;newEntities($data);
      $result = $questions-&gt;saveMany($entities, array('deep'=&gt;true, 'validate'=&gt;false, 'atomic' =&gt; true)); 
      //$question = $this-&gt;Questions-&gt;newEntity();
      if ($this-&gt;request-&gt;is('post')) {
          $result = $questions-&gt;patchEntity($result, $this-&gt;request-&gt;getData());
          if ($result) {
              $this-&gt;Flash-&gt;success(__('The question has been saved.'));
  
              return $this-&gt;redirect(['action' =&gt; 'index']);
          }
          $this-&gt;Flash-&gt;error(__('The question could not be saved. Please, try again.'));
      }
      $questionnaires = $questions-&gt;Questionnaires-&gt;find('list', ['limit' =&gt; 200]);
      $questiontypes = $questions-&gt;Questiontypes-&gt;find('list', ['limit' =&gt; 200]);
      $answers = $questions-&gt;Answers-&gt;find('list', ['limit' =&gt; 200]);
      $this-&gt;set(compact('result', 'questionnaires', 'questiontypes', 'answers'));
      
      echo &quot;&lt;pre&gt;&quot;;
      //print_r($data);
      echo &quot;&lt;/pre&gt;&quot;;
      //echo  $data['question'];
   }  
  </code></pre>
  <p><strong>here is my view code</strong></p>
  <pre><code>&lt;div class=&quot;questions form large-9 medium-8 columns content &quot; &gt;
  &lt;?= $this-&gt;Form-&gt;create($result) ?&gt;
  
  
  &lt;button class=&quot;add_field_button&quot;&gt;Add More Fields&lt;/button&gt;
      &lt;fieldset class=&quot;input_fields_wrap&quot; id=&quot;addForm&quot;&gt;
      &lt;legend&gt;&lt;?= __('Add Question') ?&gt;&lt;/legend&gt;
          
      
      &lt;?php
          echo $this-&gt;Form-&gt;control('question');
          echo $this-&gt;Form-&gt;control('questionnaire_id', ['options' =&gt; $questionnaires]);
          echo $this-&gt;Form-&gt;control('questiontype_id', ['options' =&gt; $questiontypes]);
          echo $this-&gt;Form-&gt;control('answers._ids', ['options' =&gt; $answers]);
       
      ?&gt;
      
  &lt;/fieldset&gt;
  
  &lt;?= $this-&gt;Form-&gt;button(__('Submit')) ?&gt;
  &lt;?= $this-&gt;Form-&gt;end() ?&gt;
  
  &lt;?php 
      
      echo &quot;&lt;pre&gt;&quot;;
          var_dump($result);
      echo &quot;&lt;/pre&gt;&quot;;
      
  ?&gt;
  </code></pre>
  
  <p><strong>and here is my jquery code</strong></p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
  $(document).ready(function() {
          var max_fields      = 10; //maximum input boxes allowed
          var wrapper         = $(&quot;.input_fields_wrap&quot;); //Fields wrapper
          var add_button      = $(&quot;.add_field_button&quot;); //Add button ID
          var addFormField = '&lt;?php echo $this-&gt;Form-&gt;control(&quot;question&quot;); ?&gt;'
              + '&lt;?php echo $this-&gt;Form-&gt;control(&quot;questionnaire_id&quot;, [&quot;options&quot; =&gt; $questionnaires]); ?&gt;'
              +    '&lt;?php echo $this-&gt;Form-&gt;control(&quot;questiontype_id&quot;, [&quot;options&quot; =&gt; $questiontypes]); ?&gt;'
               +   '&lt;?php echo $this-&gt;Form-&gt;control(&quot;answers._ids&quot;, [&quot;options&quot; =&gt; $answers]);?&gt;'
              ;
          var x = 1; //initlal text box count
          $(add_button).click(function(e){ //on add input button click
              e.preventDefault();
              if(x &lt; max_fields){ //max input box allowed
                  x++; //text box increment
                  $(wrapper).append(addFormField); //add input box
              }
          });
          
          $(wrapper).on(&quot;click&quot;,&quot;.remove_field&quot;, function(e){ //user click on remove text
              e.preventDefault(); $(this).parent('div').remove(); x--;
          })
      });
              
  </code></pre>