I think I know what's happening. The code above will fail if the Tvr doesn't exist already. Try this:
$qualificiation_areyou = $hook->getValue('qualificiation_areyou');
$qualificiation_emailaddress = $hook->getValue('qualificiation_emailaddress');
// set TVs to values as per form data
$projectFolderID = 19;
$tvr = $modx->getObject('modTemplateVarResource', (array('contentid' => $projectFolderID, 'tmplvarid' => 32)));
if ($tvr) {
$tvr->set('value', $qualificiation_areyou);
} else {
$tvr = $modx->newObject('modTemplateVarResource');
$tvr->set('contentid', $projectFolderId);
$tvr->set('tmplvarid', 32);
$tvr->set('value', $qualificiation_areyou);
}
$tvr->save();
$tvr = $modx->getObject('modTemplateVarResource', (array('contentid' => $projectFolderID, 'tmplvarid' => 33)));
if ($tvr) {
$tvr->set('value', $qualificiation_emailaddress);
} else {
$tvr = $modx->newObject('modTemplateVarResource');
$tvr->set('contentid', $projectFolderID);
$tvr->set('tmplvarid', 33);
$tvr->set('value', $qualificiation_emailaddress);
}
$tvr->save();
return true;
I hope this is right. I'm on vacation in Paris and using a laptop with a very small screen, so it's hard to see typos.
[ed. note: BobRay last edited this post 9 years, 11 months ago.]
Thanks Bob - really really really appreciate your assistance here! There was just one typo on the code a missing ")" after "$qualificiation_emailaddress" on 5th last line...
Good news is that now does not make the submission fall over...
Bad news is that it still does not set the value of the TV in resource 19.... have no idea why!
I do. $projectFolderId !== $projectFolderID.

My mistake.
That's not a new line. Just pointing out that the 'ID' in your $projectFolder variable in one place doesn't match the 'Id' in another.
Change them all to 'ID' and you should be in business.
Will do (though it's about 7:00 pm, so I think a beer and confit de canard -- a little late in the day for a croissant). Thanks for the kind words.