So I think I have the same issue as this post but there was no resolution posted.
https://www.chronoengine.com/forums/posts/t102392/two-db-save-to-different-tables.html#366995
I have a registration form that I want to save data to 2 tables. The form collects the parents contact information (and the parent selects the Players name). On submit I have a DBSave to the ParentInfo Table. This works fine. After that I have custom code that gets the id of the newly created ParentInfo record and puts it in field ParentId (a field in the 2nd table). per the debug this all works correctly. He is where things go bad. Then I have a DBSave to the PlayerPlayerX table (yes it is set to save to the correct table name). But instead of doing an insert to that table it does an update of the ParentInfo Table. I dont understand what is happening.
https://www.chronoengine.com/forums/posts/t102392/two-db-save-to-different-tables.html#366995
I have a registration form that I want to save data to 2 tables. The form collects the parents contact information (and the parent selects the Players name). On submit I have a DBSave to the ParentInfo Table. This works fine. After that I have custom code that gets the id of the newly created ParentInfo record and puts it in field ParentId (a field in the 2nd table). per the debug this all works correctly. He is where things go bad. Then I have a DBSave to the PlayerPlayerX table (yes it is set to save to the correct table name). But instead of doing an insert to that table it does an update of the ParentInfo Table. I dont understand what is happening.
Here is the Code
<fieldset class="chronoform-container" id="Parent1">
<legend>Parent</legend><?php
$keys = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "Players")), explode(".", "[n].id"));
$values = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "Players")), explode(".", "[n].PlayerName"));
$options = array_combine($keys, $values);
$field = array (
'name' => 'PlayerId',
'id' => 'PlayerId',
'options' =>
array (
),
'empty' => '',
'values' =>
array (
),
'label' =>
array (
'text' => 'Player Name',
'position' => 'left',
),
'sublabel' => '',
'multiple' => '0',
'size' => '',
'class' => '',
'title' => '',
'style' => '',
'params' => '',
':data-load-state' => '',
':data-tooltip' => '',
'type' => 'dropdown',
'container_id' => '31',
);
$field["options"] = $options;
echo \GCore\Helpers\Html::formLine($field["name"], $field);
?><div class="form-group gcore-form-row" id="form-row-FirstName"><label for="FirstName" class="control-label gcore-label-left">First Name</label>
<div class="gcore-input gcore-display-table" id="fin-FirstName"><input name="FirstName" id="FirstName" value="" placeholder="" class="validate['required'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /></div></div><div class="form-group gcore-form-row" id="form-row-LastName"><label for="LastName" class="control-label gcore-label-left">Last Name</label>
<div class="gcore-input gcore-display-table" id="fin-LastName"><input name="LastName" id="LastName" value="" placeholder="" class="validate['required'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /></div></div><div class="form-group gcore-form-row" id="form-row-Address1"><label for="Address1" class="control-label gcore-label-left">Address</label>
<div class="gcore-input gcore-display-table" id="fin-Address1"><input name="Address1" id="Address1" value="" placeholder="" class="validate['required'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /></div></div><div class="form-group gcore-form-row" id="form-row-City"><label for="City" class="control-label gcore-label-left">City</label>
<div class="gcore-input gcore-display-table" id="fin-City"><input name="City" id="City" value="" placeholder="" class="validate['required'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /></div></div><div class="form-group gcore-form-row" id="form-row-State"><label for="State" class="control-label gcore-label-left">State</label>
<div class="gcore-input gcore-display-table" id="fin-State"><select name="State" id="State" size="" class="validate['required'] form-control A" title="" style="" data-load-state="" data-tooltip="">
<option value=""></option>
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DC">DC</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="IA">IA</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="ME">ME</option>
<option value="MD">MD</option>
<option value="MA">MA</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MS">MS</option>
<option value="MO">MO</option>
<option value="MT">MT</option>
<option value="NE">NE</option>
<option value="NV">NV</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NY">NY</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VT">VT</option>
<option value="VA">VA</option>
<option value="WA">WA</option>
<option value="WV">WV</option>
<option value="WI">WI</option>
<option value="WY">WY</option>
</select></div></div><div class="form-group gcore-form-row" id="form-row-Zip"><label for="Zip" class="control-label gcore-label-left">Zip</label>
<div class="gcore-input gcore-display-table" id="fin-Zip"><input name="Zip" id="Zip" value="" placeholder="" class="validate['required'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /></div></div><div class="form-group gcore-form-row" id="form-row-Email1"><label for="Email1" class="control-label gcore-label-left">Email #1</label>
<div class="gcore-input gcore-display-table" id="fin-Email1"><input name="Email1" id="Email1" value="" placeholder="" class="validate['required'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /></div></div><div class="form-group gcore-form-row" id="form-row-Email2"><label for="Email2" class="control-label gcore-label-left">Email #2</label>
<div class="gcore-input gcore-display-table" id="fin-Email2"><input name="Email2" id="Email2" value="" placeholder="" class="form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /></div></div><div class="form-group gcore-form-row" id="form-row-Cell"><label for="Cell" class="control-label gcore-label-left">Cell Phone</label>
<div class="gcore-input gcore-display-table" id="fin-Cell"><input name="Cell" id="Cell" value="" placeholder="" class="validate['required'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /></div></div><?php
$keys = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "Provider")), explode(".", "[n].id"));
$values = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "Provider")), explode(".", "[n].CellProvider"));
$options = array_combine($keys, $values);
$field = array (
'name' => 'CellProvider',
'id' => 'CellProvider',
'options' =>
array (
),
'empty' => '',
'values' =>
array (
),
'label' =>
array (
'text' => 'Cell Phone Provider',
'position' => 'left',
),
'sublabel' => 'If you don\'t enter the correct provider, you won\'t get text messages',
'multiple' => '0',
'size' => '',
'class' => ' validate[\'required\']',
'title' => '',
'style' => '',
'params' => '',
':data-load-state' => '',
':data-tooltip' => '',
'type' => 'dropdown',
'container_id' => '31',
);
$field["options"] = $options;
echo \GCore\Helpers\Html::formLine($field["name"], $field);
?><input name="ParentId" id="ParentId" value="" type="hidden" class="form-control A" /></fieldset><div class="form-group gcore-form-row" id="form-row-button18"><div class="gcore-input gcore-display-table" id="fin-button18"><input name="button18" id="button18" type="submit" value="Submit" class="btn btn-default form-control A" style="" data-load-state="" /></div></div>
Hello vividal,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How do I save form data to a database table?
My form data isn't saving to the database correctly
My CFv5 form data isn't saving to the database correctly
How to load record data from a database table into your form
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How do I save form data to a database table?
My form data isn't saving to the database correctly
My CFv5 form data isn't saving to the database correctly
How to load record data from a database table into your form
P.S: I'm just an automated service😉
Here is the debug
Data Array
Array
(
[option] => com_chronoforms5
[chronoform] => ParentSelfRegister
[event] => submit
[PlayerId] => 42
[FirstName] =>xxxx
[LastName] => xxxx
[Address1] => 38 xxxxxxx
[City] => xxxxxxxxx
[State] => xxxx
[Zip] => xxxx
[Email1] => xxxxxx
[Email2] => xxxxxxx
[Cell] => xxxxxxxx
[CellProvider] => 6
[ParentId] => 65
[button18] => Submit
[id] => 65
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
[6] => Array
(
[DB Save] => Array
(
[Queries] => Array
(
[0] => INSERT INTO `LO_ParentInfo` (`PlayerId`, `FirstName`, `LastName`, `Address1`, `City`, `State`, `Zip`, `Email1`, `Email2`, `Cell`, `CellProvider`, `user_id`, `uniq_id`, `created`) values ('42', xxxxx', 'xxxx', '38 XXXXX', 'xxxxxx', 'xx', 'xxxxx', 'XXXXXX', 'XXXXXXX', 'xxxxxxxxxx', '6', '638', 'ceae6098542fcd906cc22a039fdd78787c25d8b8', '2017-04-16 14:58:55');
)
)
)
[17] => Array
(
[DB Save] => Array
(
[Queries] => Array
(
[0] => UPDATE `LO_ParentInfo` AS `Data` SET `PlayerId` = '42', `FirstName` = 'xxxxx', `LastName` = 'xxxxx', `Address1` = '38 xxxxxxxx', `City` = 'xxxxxxx', `State` = 'xx', `Zip` = 'xxxxxx', `Email1` = 'xxxxxxx', `Email2` = 'xxxxxx', `Cell` = 'xxxxxxx', `CellProvider` = '6', `user_id` = '638', `modified` = '2017-04-16 14:58:55' WHERE `id` = '65';
)
)
)
)
Hi,
You are loading this form inside an article ? if yes then please test the form as standalone and check if it works as expected ?
Best regards,
Max
You are loading this form inside an article ? if yes then please test the form as standalone and check if it works as expected ?
Best regards,
Max
This topic is locked and no more replies can be posted.