How to insert a new record in an associated belongsTo table instead of editing the associated oneCakePHP: How to update multiple records at the same time with the Form helperCakePHP How can I save many records in a link table at once for user - map - attributes?CakePHP-3.0 multiple belongsTo associationsCakephp editing BelongsTo associated fieldMultiple belongsTo() associations in CakePHP 3.xCakephp 3, Updating associated belongsto Data2 belongsTo associations on the same table in cakePHP 3multiple select for hasMany association in CakePHP 3cant save associated new records in cakephp3Cakephp 3 - save data to belongstomany table

Impossible Scrabble Words

Unpredictability of Stock Market

Have you ever been issued a passport or national identity card for travel by any other country?

Is there a theorem in Real analysis similar to Cauchy's theorem in Complex analysis?

How to convert Mn2O3 to Mn3O4?

Delete empty subfolders, keep parent folder

Permutations in Disguise

6+8=71 move two matches

Output Distinct Factor Cuboids

Exam design: give maximum score per question or not?

Can a business put whatever they want into a contract?

Why 1.5fill is 0pt

In Bb5 systems against the Sicilian, why does White exchange their b5 bishop without playing a6?

Should I inform my future product owner that there are big chances that a team member will leave the company soon?

Did slaves have slaves?

How to install Rasbian Stretch on Raspberry Pi 4?

Does Forgotten Realms setting count as “High magic”?

What does the "capacitor into resistance" symbol mean?

Are lay articles good enough to be the main source of information for PhD research?

What is this WWII four-engine plane on skis?

Who are the people reviewing far more papers than they're submitting for review?

How to set a tolerance level for equality constraints

Writing a system of Linear Equations

Python web-scraper to download table of transistor counts from Wikipedia



How to insert a new record in an associated belongsTo table instead of editing the associated one


CakePHP: How to update multiple records at the same time with the Form helperCakePHP How can I save many records in a link table at once for user - map - attributes?CakePHP-3.0 multiple belongsTo associationsCakephp editing BelongsTo associated fieldMultiple belongsTo() associations in CakePHP 3.xCakephp 3, Updating associated belongsto Data2 belongsTo associations on the same table in cakePHP 3multiple select for hasMany association in CakePHP 3cant save associated new records in cakephp3Cakephp 3 - save data to belongstomany table






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















In a edit-template, I created 2 forms. The first to edit a record from 'Table1' and a second form to add an record to the associated (belongsTo) table 'Table2'. I don't want to edit the associated record but add a new one in Table2 and change the bindingkey of the record from 'Table1'.



In the controller I use patchEntity(), but this way the original linked record in 'Table2' is edited.



The code for the second form look like this.



 <?= $this->Form->create($machine, ['url' => ['action' => 'edit_foto']]);?>
<?= $this->Form->controls([
'id' => ['type' => 'hidden'],
'foto.omschrijving' => [
'type' => 'text',
'label' => __('naam van de machine'),
'value' => $result->type_machine
], []);?>

<?= $this->Form->button(__('save'), ['type' => 'submit']); ?>
<?= $this->Form->end(); ?>


In the controller for 'Table1' I use something like this.



public function editFoto($id) 

$data = $this->getRequest()->getData();
$machine = $this->Machines->get($id, [
'contain' => [
'Foto'
]
]);

if ($this->request->is([
'patch',
'post',
'put'
]))

$machine = $this->Machines->patchEntity($machine, $data);
if ($this->Machines->save($machine))
$this->Flash->success(__('Machine naam has been saved.', [
'naam' => $machine['naam']
]));
return $this->redirect(['action' => 'edit', $id]);






How can I prevent the controller from editing the original record and instead force to add a new record in 'Table2' and change the bindingkey in 'Table1'?



Help is much appreciated.



added information:
the data send by the form looks like:



[
'id' => '87',
'foto' => [
'omschrijving' => 'WAKER 135 - ter - testje',
'foto' => [
'tmp_name' => 'C:xampptmpphp6CFD.tmp',
'error' => (int) 0,
'name' => 'MAKITA DTD153RTJ accuschroevendraaier.jpg',
'type' => 'image/jpeg',
'size' => (int) 188971
],
'dir_id' => '5c9dd428cc4ef'
]
]









share|improve this question
































    0















    In a edit-template, I created 2 forms. The first to edit a record from 'Table1' and a second form to add an record to the associated (belongsTo) table 'Table2'. I don't want to edit the associated record but add a new one in Table2 and change the bindingkey of the record from 'Table1'.



    In the controller I use patchEntity(), but this way the original linked record in 'Table2' is edited.



    The code for the second form look like this.



     <?= $this->Form->create($machine, ['url' => ['action' => 'edit_foto']]);?>
    <?= $this->Form->controls([
    'id' => ['type' => 'hidden'],
    'foto.omschrijving' => [
    'type' => 'text',
    'label' => __('naam van de machine'),
    'value' => $result->type_machine
    ], []);?>

    <?= $this->Form->button(__('save'), ['type' => 'submit']); ?>
    <?= $this->Form->end(); ?>


    In the controller for 'Table1' I use something like this.



    public function editFoto($id) 

    $data = $this->getRequest()->getData();
    $machine = $this->Machines->get($id, [
    'contain' => [
    'Foto'
    ]
    ]);

    if ($this->request->is([
    'patch',
    'post',
    'put'
    ]))

    $machine = $this->Machines->patchEntity($machine, $data);
    if ($this->Machines->save($machine))
    $this->Flash->success(__('Machine naam has been saved.', [
    'naam' => $machine['naam']
    ]));
    return $this->redirect(['action' => 'edit', $id]);






    How can I prevent the controller from editing the original record and instead force to add a new record in 'Table2' and change the bindingkey in 'Table1'?



    Help is much appreciated.



    added information:
    the data send by the form looks like:



    [
    'id' => '87',
    'foto' => [
    'omschrijving' => 'WAKER 135 - ter - testje',
    'foto' => [
    'tmp_name' => 'C:xampptmpphp6CFD.tmp',
    'error' => (int) 0,
    'name' => 'MAKITA DTD153RTJ accuschroevendraaier.jpg',
    'type' => 'image/jpeg',
    'size' => (int) 188971
    ],
    'dir_id' => '5c9dd428cc4ef'
    ]
    ]









    share|improve this question




























      0












      0








      0








      In a edit-template, I created 2 forms. The first to edit a record from 'Table1' and a second form to add an record to the associated (belongsTo) table 'Table2'. I don't want to edit the associated record but add a new one in Table2 and change the bindingkey of the record from 'Table1'.



      In the controller I use patchEntity(), but this way the original linked record in 'Table2' is edited.



      The code for the second form look like this.



       <?= $this->Form->create($machine, ['url' => ['action' => 'edit_foto']]);?>
      <?= $this->Form->controls([
      'id' => ['type' => 'hidden'],
      'foto.omschrijving' => [
      'type' => 'text',
      'label' => __('naam van de machine'),
      'value' => $result->type_machine
      ], []);?>

      <?= $this->Form->button(__('save'), ['type' => 'submit']); ?>
      <?= $this->Form->end(); ?>


      In the controller for 'Table1' I use something like this.



      public function editFoto($id) 

      $data = $this->getRequest()->getData();
      $machine = $this->Machines->get($id, [
      'contain' => [
      'Foto'
      ]
      ]);

      if ($this->request->is([
      'patch',
      'post',
      'put'
      ]))

      $machine = $this->Machines->patchEntity($machine, $data);
      if ($this->Machines->save($machine))
      $this->Flash->success(__('Machine naam has been saved.', [
      'naam' => $machine['naam']
      ]));
      return $this->redirect(['action' => 'edit', $id]);






      How can I prevent the controller from editing the original record and instead force to add a new record in 'Table2' and change the bindingkey in 'Table1'?



      Help is much appreciated.



      added information:
      the data send by the form looks like:



      [
      'id' => '87',
      'foto' => [
      'omschrijving' => 'WAKER 135 - ter - testje',
      'foto' => [
      'tmp_name' => 'C:xampptmpphp6CFD.tmp',
      'error' => (int) 0,
      'name' => 'MAKITA DTD153RTJ accuschroevendraaier.jpg',
      'type' => 'image/jpeg',
      'size' => (int) 188971
      ],
      'dir_id' => '5c9dd428cc4ef'
      ]
      ]









      share|improve this question
















      In a edit-template, I created 2 forms. The first to edit a record from 'Table1' and a second form to add an record to the associated (belongsTo) table 'Table2'. I don't want to edit the associated record but add a new one in Table2 and change the bindingkey of the record from 'Table1'.



      In the controller I use patchEntity(), but this way the original linked record in 'Table2' is edited.



      The code for the second form look like this.



       <?= $this->Form->create($machine, ['url' => ['action' => 'edit_foto']]);?>
      <?= $this->Form->controls([
      'id' => ['type' => 'hidden'],
      'foto.omschrijving' => [
      'type' => 'text',
      'label' => __('naam van de machine'),
      'value' => $result->type_machine
      ], []);?>

      <?= $this->Form->button(__('save'), ['type' => 'submit']); ?>
      <?= $this->Form->end(); ?>


      In the controller for 'Table1' I use something like this.



      public function editFoto($id) 

      $data = $this->getRequest()->getData();
      $machine = $this->Machines->get($id, [
      'contain' => [
      'Foto'
      ]
      ]);

      if ($this->request->is([
      'patch',
      'post',
      'put'
      ]))

      $machine = $this->Machines->patchEntity($machine, $data);
      if ($this->Machines->save($machine))
      $this->Flash->success(__('Machine naam has been saved.', [
      'naam' => $machine['naam']
      ]));
      return $this->redirect(['action' => 'edit', $id]);






      How can I prevent the controller from editing the original record and instead force to add a new record in 'Table2' and change the bindingkey in 'Table1'?



      Help is much appreciated.



      added information:
      the data send by the form looks like:



      [
      'id' => '87',
      'foto' => [
      'omschrijving' => 'WAKER 135 - ter - testje',
      'foto' => [
      'tmp_name' => 'C:xampptmpphp6CFD.tmp',
      'error' => (int) 0,
      'name' => 'MAKITA DTD153RTJ accuschroevendraaier.jpg',
      'type' => 'image/jpeg',
      'size' => (int) 188971
      ],
      'dir_id' => '5c9dd428cc4ef'
      ]
      ]






      cakephp cakephp-3.0






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 29 at 8:21







      Gubberrr

















      asked Mar 27 at 13:36









      GubberrrGubberrr

      4713 bronze badges




      4713 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          Instead of



          $machine = $this->Machines->patchEntity($machine, $data);
          $this->Machines->save($machine);


          you should use



          $machine = $this->Machines->newEntity($data, [
          'associated' => ['Fotos']
          ]);
          $this->Machines->save($machine);


          to save the data. If the associations between Table1 and Table2 are correct in the models, this will also update the binding keys.



          Make sure, the format of the ids in FormHelper is correct. See the docs, how to handle Saving With Associations. You can see this in $data. When submitting the form, $data should be in the following format:



          $data = [
          'id' => '...',
          'foto' => [
          // ... model data
          ],
          ];





          share|improve this answer



























          • Then i get an error: "Argument 1 passed to CakeORMMarshaller::one() must be of the type array, object given, called in C:xampphtdocsmyKMGvendorcakephpcakephpsrcORMTable.php on line 2631 and defined [COREsrcORMMarshaller.php, line 168]"

            – Gubberrr
            Mar 28 at 15:42












          • I updated my answer. Maybe you used $machine instead of $data as a parameter?

            – mixable
            Mar 28 at 15:45











          • Tanx, $data is saved as a new record, but the binding_key hasn't changed. Here is my code in the model: " $this->belongsTo('Foto', [ 'className' => 'Fotos', foreignKey' => 'foto_id' ]);", if it can help you out.

            – Gubberrr
            Mar 28 at 16:30











          • I updated my answer. You can use the associated parameter when creating an entity. In addition, please check the format of $data. The method save() will handle associations automatically if the format is correct.

            – mixable
            Mar 28 at 16:58











          • With or without the associated parameter, it does the same. When I debug both saved values $machines->foto->id and $machines->foto_id, I get the correct new value. It looks like the data in the redirected action isn't updated. After a successfull saving, it should redirect to the main form1 (action = edit), and reload the changed record (machine) with the new foto, shouldn't it?

            – Gubberrr
            Mar 29 at 8:30











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378564%2fhow-to-insert-a-new-record-in-an-associated-belongsto-table-instead-of-editing-t%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0
















          Instead of



          $machine = $this->Machines->patchEntity($machine, $data);
          $this->Machines->save($machine);


          you should use



          $machine = $this->Machines->newEntity($data, [
          'associated' => ['Fotos']
          ]);
          $this->Machines->save($machine);


          to save the data. If the associations between Table1 and Table2 are correct in the models, this will also update the binding keys.



          Make sure, the format of the ids in FormHelper is correct. See the docs, how to handle Saving With Associations. You can see this in $data. When submitting the form, $data should be in the following format:



          $data = [
          'id' => '...',
          'foto' => [
          // ... model data
          ],
          ];





          share|improve this answer



























          • Then i get an error: "Argument 1 passed to CakeORMMarshaller::one() must be of the type array, object given, called in C:xampphtdocsmyKMGvendorcakephpcakephpsrcORMTable.php on line 2631 and defined [COREsrcORMMarshaller.php, line 168]"

            – Gubberrr
            Mar 28 at 15:42












          • I updated my answer. Maybe you used $machine instead of $data as a parameter?

            – mixable
            Mar 28 at 15:45











          • Tanx, $data is saved as a new record, but the binding_key hasn't changed. Here is my code in the model: " $this->belongsTo('Foto', [ 'className' => 'Fotos', foreignKey' => 'foto_id' ]);", if it can help you out.

            – Gubberrr
            Mar 28 at 16:30











          • I updated my answer. You can use the associated parameter when creating an entity. In addition, please check the format of $data. The method save() will handle associations automatically if the format is correct.

            – mixable
            Mar 28 at 16:58











          • With or without the associated parameter, it does the same. When I debug both saved values $machines->foto->id and $machines->foto_id, I get the correct new value. It looks like the data in the redirected action isn't updated. After a successfull saving, it should redirect to the main form1 (action = edit), and reload the changed record (machine) with the new foto, shouldn't it?

            – Gubberrr
            Mar 29 at 8:30
















          0
















          Instead of



          $machine = $this->Machines->patchEntity($machine, $data);
          $this->Machines->save($machine);


          you should use



          $machine = $this->Machines->newEntity($data, [
          'associated' => ['Fotos']
          ]);
          $this->Machines->save($machine);


          to save the data. If the associations between Table1 and Table2 are correct in the models, this will also update the binding keys.



          Make sure, the format of the ids in FormHelper is correct. See the docs, how to handle Saving With Associations. You can see this in $data. When submitting the form, $data should be in the following format:



          $data = [
          'id' => '...',
          'foto' => [
          // ... model data
          ],
          ];





          share|improve this answer



























          • Then i get an error: "Argument 1 passed to CakeORMMarshaller::one() must be of the type array, object given, called in C:xampphtdocsmyKMGvendorcakephpcakephpsrcORMTable.php on line 2631 and defined [COREsrcORMMarshaller.php, line 168]"

            – Gubberrr
            Mar 28 at 15:42












          • I updated my answer. Maybe you used $machine instead of $data as a parameter?

            – mixable
            Mar 28 at 15:45











          • Tanx, $data is saved as a new record, but the binding_key hasn't changed. Here is my code in the model: " $this->belongsTo('Foto', [ 'className' => 'Fotos', foreignKey' => 'foto_id' ]);", if it can help you out.

            – Gubberrr
            Mar 28 at 16:30











          • I updated my answer. You can use the associated parameter when creating an entity. In addition, please check the format of $data. The method save() will handle associations automatically if the format is correct.

            – mixable
            Mar 28 at 16:58











          • With or without the associated parameter, it does the same. When I debug both saved values $machines->foto->id and $machines->foto_id, I get the correct new value. It looks like the data in the redirected action isn't updated. After a successfull saving, it should redirect to the main form1 (action = edit), and reload the changed record (machine) with the new foto, shouldn't it?

            – Gubberrr
            Mar 29 at 8:30














          0














          0










          0









          Instead of



          $machine = $this->Machines->patchEntity($machine, $data);
          $this->Machines->save($machine);


          you should use



          $machine = $this->Machines->newEntity($data, [
          'associated' => ['Fotos']
          ]);
          $this->Machines->save($machine);


          to save the data. If the associations between Table1 and Table2 are correct in the models, this will also update the binding keys.



          Make sure, the format of the ids in FormHelper is correct. See the docs, how to handle Saving With Associations. You can see this in $data. When submitting the form, $data should be in the following format:



          $data = [
          'id' => '...',
          'foto' => [
          // ... model data
          ],
          ];





          share|improve this answer















          Instead of



          $machine = $this->Machines->patchEntity($machine, $data);
          $this->Machines->save($machine);


          you should use



          $machine = $this->Machines->newEntity($data, [
          'associated' => ['Fotos']
          ]);
          $this->Machines->save($machine);


          to save the data. If the associations between Table1 and Table2 are correct in the models, this will also update the binding keys.



          Make sure, the format of the ids in FormHelper is correct. See the docs, how to handle Saving With Associations. You can see this in $data. When submitting the form, $data should be in the following format:



          $data = [
          'id' => '...',
          'foto' => [
          // ... model data
          ],
          ];






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 28 at 16:54

























          answered Mar 28 at 12:57









          mixablemixable

          5746 silver badges31 bronze badges




          5746 silver badges31 bronze badges















          • Then i get an error: "Argument 1 passed to CakeORMMarshaller::one() must be of the type array, object given, called in C:xampphtdocsmyKMGvendorcakephpcakephpsrcORMTable.php on line 2631 and defined [COREsrcORMMarshaller.php, line 168]"

            – Gubberrr
            Mar 28 at 15:42












          • I updated my answer. Maybe you used $machine instead of $data as a parameter?

            – mixable
            Mar 28 at 15:45











          • Tanx, $data is saved as a new record, but the binding_key hasn't changed. Here is my code in the model: " $this->belongsTo('Foto', [ 'className' => 'Fotos', foreignKey' => 'foto_id' ]);", if it can help you out.

            – Gubberrr
            Mar 28 at 16:30











          • I updated my answer. You can use the associated parameter when creating an entity. In addition, please check the format of $data. The method save() will handle associations automatically if the format is correct.

            – mixable
            Mar 28 at 16:58











          • With or without the associated parameter, it does the same. When I debug both saved values $machines->foto->id and $machines->foto_id, I get the correct new value. It looks like the data in the redirected action isn't updated. After a successfull saving, it should redirect to the main form1 (action = edit), and reload the changed record (machine) with the new foto, shouldn't it?

            – Gubberrr
            Mar 29 at 8:30


















          • Then i get an error: "Argument 1 passed to CakeORMMarshaller::one() must be of the type array, object given, called in C:xampphtdocsmyKMGvendorcakephpcakephpsrcORMTable.php on line 2631 and defined [COREsrcORMMarshaller.php, line 168]"

            – Gubberrr
            Mar 28 at 15:42












          • I updated my answer. Maybe you used $machine instead of $data as a parameter?

            – mixable
            Mar 28 at 15:45











          • Tanx, $data is saved as a new record, but the binding_key hasn't changed. Here is my code in the model: " $this->belongsTo('Foto', [ 'className' => 'Fotos', foreignKey' => 'foto_id' ]);", if it can help you out.

            – Gubberrr
            Mar 28 at 16:30











          • I updated my answer. You can use the associated parameter when creating an entity. In addition, please check the format of $data. The method save() will handle associations automatically if the format is correct.

            – mixable
            Mar 28 at 16:58











          • With or without the associated parameter, it does the same. When I debug both saved values $machines->foto->id and $machines->foto_id, I get the correct new value. It looks like the data in the redirected action isn't updated. After a successfull saving, it should redirect to the main form1 (action = edit), and reload the changed record (machine) with the new foto, shouldn't it?

            – Gubberrr
            Mar 29 at 8:30

















          Then i get an error: "Argument 1 passed to CakeORMMarshaller::one() must be of the type array, object given, called in C:xampphtdocsmyKMGvendorcakephpcakephpsrcORMTable.php on line 2631 and defined [COREsrcORMMarshaller.php, line 168]"

          – Gubberrr
          Mar 28 at 15:42






          Then i get an error: "Argument 1 passed to CakeORMMarshaller::one() must be of the type array, object given, called in C:xampphtdocsmyKMGvendorcakephpcakephpsrcORMTable.php on line 2631 and defined [COREsrcORMMarshaller.php, line 168]"

          – Gubberrr
          Mar 28 at 15:42














          I updated my answer. Maybe you used $machine instead of $data as a parameter?

          – mixable
          Mar 28 at 15:45





          I updated my answer. Maybe you used $machine instead of $data as a parameter?

          – mixable
          Mar 28 at 15:45













          Tanx, $data is saved as a new record, but the binding_key hasn't changed. Here is my code in the model: " $this->belongsTo('Foto', [ 'className' => 'Fotos', foreignKey' => 'foto_id' ]);", if it can help you out.

          – Gubberrr
          Mar 28 at 16:30





          Tanx, $data is saved as a new record, but the binding_key hasn't changed. Here is my code in the model: " $this->belongsTo('Foto', [ 'className' => 'Fotos', foreignKey' => 'foto_id' ]);", if it can help you out.

          – Gubberrr
          Mar 28 at 16:30













          I updated my answer. You can use the associated parameter when creating an entity. In addition, please check the format of $data. The method save() will handle associations automatically if the format is correct.

          – mixable
          Mar 28 at 16:58





          I updated my answer. You can use the associated parameter when creating an entity. In addition, please check the format of $data. The method save() will handle associations automatically if the format is correct.

          – mixable
          Mar 28 at 16:58













          With or without the associated parameter, it does the same. When I debug both saved values $machines->foto->id and $machines->foto_id, I get the correct new value. It looks like the data in the redirected action isn't updated. After a successfull saving, it should redirect to the main form1 (action = edit), and reload the changed record (machine) with the new foto, shouldn't it?

          – Gubberrr
          Mar 29 at 8:30






          With or without the associated parameter, it does the same. When I debug both saved values $machines->foto->id and $machines->foto_id, I get the correct new value. It looks like the data in the redirected action isn't updated. After a successfull saving, it should redirect to the main form1 (action = edit), and reload the changed record (machine) with the new foto, shouldn't it?

          – Gubberrr
          Mar 29 at 8:30









          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378564%2fhow-to-insert-a-new-record-in-an-associated-belongsto-table-instead-of-editing-t%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript