CSV Import Validation
Posted: 2022-08-28 18:54
Hi everyone, I am trying to get some validation working on the csv import. Jsetzer has provided some guidance here - viewtopic.php?f=8&t=4858 but unfortunately this is beyond me. I have looked at ronthedev's plugin but this did not have any validation examples.
I have tried adding this in hooks/import-csv.php
This worked up to a point but it fails on this part
has anyone got this working already that they could share with me?
I have tried adding this in hooks/import-csv.php
Code: Select all
$transformFunctions['testtable'] = function($data, $options = []) {
// new definition here
// then you must return transformed data
if($data['ContractID'] === '' ) {
exit;
}
if($data['Name'] === '' && $data['UnitIdentifer'] === '' ) {
exit;
}
if(pkGivenLookupText($data['ContractID'], 'testtable', 'ContractID') == '' ) {
exit;
}
return $data;
};
Code: Select all
if(pkGivenLookupText($data['ContractID'], 'testtable', 'ContractID') == '' ) {
exit;
}