Hi Bob and Max,
Long tiime, no speak. Its been almost exactly a year since I needed your help. Great tenstament to the stability of the product.
I have a intertesting one for you.
Both the attached forms have been working for over 1 year. One provides the abvaility to submit match reports from the local soccer games and the other, allows news reports for club newsletter to be submitted. Both forms gather inputs, restructure the inputs into std fields to be saved in the std 'contents' table in J2.5 in an 'unpublished' state. However, recently, the matchreportsubmission form has started failing. As far as I can tell, aside for Joomla updates, no other extension or template has been changed.
The failing form gathers input OK, and send emails to multiple parites OK (email after DB save), however the DB save is not working. It fails to insert in the 'contents' table of the DB.
In comparison, the other form (newsreportsubmission) which has almost identical custom code, works fine.
I have worked this over and over and can't get the DB insert to start working again. I nned some insight from minds greater than mine. The attached are std backups, just renamed as .txt's
Looking fwd to your thoughts.
regards,
Anthony.
Long tiime, no speak. Its been almost exactly a year since I needed your help. Great tenstament to the stability of the product.
I have a intertesting one for you.
Both the attached forms have been working for over 1 year. One provides the abvaility to submit match reports from the local soccer games and the other, allows news reports for club newsletter to be submitted. Both forms gather inputs, restructure the inputs into std fields to be saved in the std 'contents' table in J2.5 in an 'unpublished' state. However, recently, the matchreportsubmission form has started failing. As far as I can tell, aside for Joomla updates, no other extension or template has been changed.
The failing form gathers input OK, and send emails to multiple parites OK (email after DB save), however the DB save is not working. It fails to insert in the 'contents' table of the DB.
In comparison, the other form (newsreportsubmission) which has almost identical custom code, works fine.
I have worked this over and over and can't get the DB insert to start working again. I nned some insight from minds greater than mine. The attached are std backups, just renamed as .txt's
Looking fwd to your thoughts.
regards,
Anthony.
Hi Anthony,
I don't see anything immediately obvious with the form. What do you see when you add a debugger action?
Bob
I don't see anything immediately obvious with the form. What do you see when you add a debugger action?
Bob
Hi Anthony,
The debug reports appear to show successful saves to records 116 and 2020.
Bob
* Rather than upload the whole page it's enough to click the Code icon </> and copy and paste the debug report part into your post here.
The debug reports appear to show successful saves to records 116 and 2020.
Bob
* Rather than upload the whole page it's enough to click the Code icon </> and copy and paste the debug report part into your post here.
Hi Bob,
Thanks for the tip.
I did another test with debugging on. The working form inserted a record at 2021 (as anticipated). The form that fails seems to be trying to insert to the same ID # (116) as the previous test I sent you. (chronoform_data_id] => 116.)
Why would that be?
Thanks for the tip.
I did another test with debugging on. The working form inserted a record at 2021 (as anticipated). The form that fails seems to be trying to insert to the same ID # (116) as the previous test I sent you. (chronoform_data_id] => 116.)
Why would that be?
Hi Anthony,
I got it.
You have an input called id with a value of 116 so that record is always being updated rather than a new one being created. It's probably the Article ID from the URL that sets it.
Add a Custom Code action to the form On Submit event before the DB Save action with code like this in it:
Bob
[[> Later: updated to fix a typo. <]]
[[> Later: updated to fix another typo. <]]
I got it.
You have an input called id with a value of 116 so that record is always being updated rather than a new one being created. It's probably the Article ID from the URL that sets it.
Add a Custom Code action to the form On Submit event before the DB Save action with code like this in it:
<?php
if ( isset($form->data['id']) {
unset($form->data['id']);
}
?>
I think that should do it.
Bob
[[> Later: updated to fix a typo. <]]
[[> Later: updated to fix another typo. <]]
Hi Bob,
no luck but....
in the info below. there are 3 fields that do not appear in any of my other forms. 'view', 'layout', 'id'
these 3 fields refer to a content category with an ID of 116 (no wonder it won;t write to the DB. Its trying to overwrite a category). Why would CF drag the view type (category) and the layout 'blog' intot the array.
Matchreport submission debugger extract
Anthony
no luck but....
in the info below. there are 3 fields that do not appear in any of my other forms. 'view', 'layout', 'id'
these 3 fields refer to a content category with an ID of 116 (no wonder it won;t write to the DB. Its trying to overwrite a category). Why would CF drag the view type (category) and the layout 'blog' intot the array.
Matchreport submission debugger extract
Data Array:
Array
(
[option] => com_chronoforms
[chronoform] => cf4_match_report_submission_form-20140429
[event] => submit
[Itemid] => 255
[view] => category
[layout] => blog
[id] => 116
[gender] => men
[ageGroup] => U7
[division] => 14
[team] => Red C
Anthony
Hi Anthony,
Please try replacing is_set with isset ( my typo - now corrected).
The problem is with the id field. ChronoForms grabs all the parameters from the page URL and adds them to the $form->data array automatically. This can be really useful but can also cause problems like this.
Bob
PS The alternative fix is to make sure that any tables you create don't use 'id' as the primary key. But of course you can't change that with many existing tables.
Please try replacing is_set with isset ( my typo - now corrected).
The problem is with the id field. ChronoForms grabs all the parameters from the page URL and adds them to the $form->data array automatically. This can be really useful but can also cause problems like this.
Bob
PS The alternative fix is to make sure that any tables you create don't use 'id' as the primary key. But of course you can't change that with many existing tables.
Hi Bob,
no luck😢
This is the debuuger output
This is the code that generated the debugger outcome
It doesn't appear that the unset is having an effect.
thoughts.
-anthony
no luck😢
This is the debuuger output
Data Array:
Array
(
[option] => com_chronoforms
[chronoform] => cf4_match_report_submission_form-20140429
[event] => submit
[Itemid] => 255
[view] => category
[layout] => blog
[id] => 116
[gender] => men
[ageGroup] => U18
[division] => 11
[team] => Green A
[oppositionTeam] => gfsdfg
[matchDate] => 2014-05-01
[wphcfcScore] => 0
[oppositionScore] => 0
[matchReport] => gfdsdfgdf
[articleImage1] =>
[articleReporterName] => a
[authorEmailAddress] => aj_watts@optusnet.com.au
[chrono_verification] => itmts
[input_submit_40] => Submit
[4a7c1aa87c0e440c5d1aabd13a949898] => 1
[_PLUGINS_] =>
[title] => U18/11-Green A - 0 vs 0 - GFSDFG - Played: 2014-05-01
[fulltext] => Editor Info - Delete everything above & including the ===== line before publishing
Ladies or Mens: men
Match Picture Filename:
==================================
gfdsdfgdf
Club Logo
[catid] => 81
[state] => 0
[created] => 2014-05-01 00:00:00
[created_by_alias] => a
[publish_down] => 20141101
[chronoform_data] => Array
(
[cf_modified] => 2014-05-01 03:57:54
[cf_modified_by] => 0
[option] => com_chronoforms
[chronoform] => cf4_match_report_submission_form-20140429
[event] => submit
[Itemid] => 255
[view] => category
[layout] => blog
[id] => 116
[gender] => men
[ageGroup] => U18
[division] => 11
[team] => Green A
[oppositionTeam] => gfsdfg
[matchDate] => 2014-05-01
[wphcfcScore] => 0
[oppositionScore] => 0
[matchReport] => gfdsdfgdf
[articleImage1] =>
[articleReporterName] => a
[authorEmailAddress] => aj_watts@optusnet.com.au
[chrono_verification] => itmts
[input_submit_40] => Submit
[4a7c1aa87c0e440c5d1aabd13a949898] => 1
[_PLUGINS_] =>
[title] => U18/11-Green A - 0 vs 0 - GFSDFG - Played: 2014-05-01
[fulltext] => Editor Info - Delete everything above & including the ===== line before publishing
Ladies or Mens: men
Match Picture Filename:
==================================
gfdsdfgdf
Club Logo
[catid] => 81
[state] => 0
[created] => 2014-05-01 00:00:00
[created_by_alias] => a
[publish_down] => 20141101
)
[chronoform_data_id] => 116
)
This is the code that generated the debugger outcome
<?php
//
// updated 2014-04-29
// remove 'id' filed in db write section
//capture form variables
//
$gender = $_POST['gender'];
$ageGrp = $_POST['ageGroup'];
$division = $_POST['division'];
$team = $_POST['team'];
if (($division != "N/A") && ($team != "N/A")){
$wphcfcTeam = $ageGrp . '/' . $division .'-' . $team;
}
elseif (($division != "N/A") && ($team == "N/A")){
$wphcfcTeam = $ageGrp . '/' . $division;
}
elseif (($division == "N/A") && ($team != "N/A")){
$wphcfcTeam = $ageGrp . '/' . $team;
}
else {
$wphcfcTeam = $ageGrp;
}
$oppTeam = strtoupper($_POST['oppositionTeam']);
$matchDate = $_POST['matchDate'];
$mDate = strtotime($_POST['matchDate']);
$wphcfcScore = $_POST['wphcfcScore'];
$oppScore = $_POST['oppositionScore'];
$matchReport = $_POST['matchReport'];
$articlePicture1 = $form->data['articleImage1'];
$publish_end_date = date("Y"). '11' . '01';
$reporterName = $_POST['articleReporterName'];
//creatreport components
$matchReportTitle = $wphcfcTeam . ' - ' . $wphcfcScore . ' vs '. $oppScore . ' - ' . $oppTeam .' - Played: ' . $matchDate;
$editorsInfo = '<b>Editor Info - Delete everything above & including the ===== line before publishing</b><p>Ladies or Mens: ' . $gender . '</p><p>Match Picture Filename: ' . $articlePicture . '</p><p>==================================</p>';
//if (strpos($articlePicture, "NOFILE") !== false)
if ($articlePicture1 =="")
{
$matchReportBody = '<p>' . $matchReport . '</p>';
}
else
{
$matchReportBody = '<p>' . $matchReport . '</p>'. '<br><img src="images/stories/matchReports/'. $articlePicture1 . '" alt="Match Picture1" width="320"/><br>';
}
//assemble report
$form->data['title'] = $matchReportTitle;
$form->data['fulltext'] = $editorsInfo . '<br>' . $matchReportBody . '<br><br><img src="images/stories/club_logo_100_100.jpg" alt="Club Logo" width="50" height="50"/>';
$form->data['catid'] = '81';
$form->data['state'] = '0';
$form->data['created'] = date("Y-m-d H:i:s", $mDate);
$form->data['created_by_alias'] = $reporterName;
$form->data['publish_down'] = $publish_end_date;
if (isset($form->data['id']) {
unset($form->data['id'];
}
?>
It doesn't appear that the unset is having an effect.
thoughts.
-anthony
Thanks.
added missing ) as suggested. no luck. it seems [id] is locked in the array. I even tried setting it to a null in the form -> data lines to no avail.
am I putting the code in the right place. at the moment, the custom code is the step immediately prior to the db save. should it be earlier, for example, just after the html load
-Anthony
added missing ) as suggested. no luck. it seems [id] is locked in the array. I even tried setting it to a null in the form -> data lines to no avail.
am I putting the code in the right place. at the moment, the custom code is the step immediately prior to the db save. should it be earlier, for example, just after the html load
-Anthony
Hi Anthony,
:-( Just spotted another missing ) in the isset line
Bob
:-( Just spotted another missing ) in the isset line
<?php
if ( isset($form->data['id']) ) {
unset($form->data['id']);
}
?>
Sorry, this is way over my normal typo level :-(
Bob
This topic is locked and no more replies can be posted.