I have multiple custom database table and I have formit2db working or seemingly working. I'm not completely proficient with xPDO or PHP, but I'm kind of feeling my way through it based on the various tutorials and posts to this board.
I have created 2 snippets for gathering id's from various tables.
The first one is pulling the user id of the current logged in user:
$UserID = $modx->user->get('id');
return $UserID;
Pretty straight forward and seems to be working. My second snippet is what's causing me issues.
$UserID = $modx->user->get('id');
$path = MODX_CORE_PATH . 'components/companyProfiles/';
$result = $modx->addPackage('companyProfiles',$path .
'model/');
/*if (! $result) {
return 'failed to add package';
} else {
$output = '<p>added Package</p>';
}*/
$companies = $modx->getObject('companyProfile',array('FK_UserId'=>$UserID));
$output = $companies->get('id');
return $output;
Basically, I want to output the ID of the companyProfile table where the FK_UserId fields equals the current User ID. It's outputting an ID, but there may be a better and more efficient way of doing this. My problem is when I try to insert it into the database with formit2db. All fields are inserting correctly except for the companyID. I have the field value="[[!getCompanyID]]" and it shows the value it should in the field, but it's not inserting into the table. The value for [[!getUserID]] is working fine, so maybe there's something wrong with the snippet?