[SOLVED] CSV import, user_id always saving as zero

chozma

Member
Hi guys,

I would like the user to be able to import some records using a CSV file via the front end. The table that the records will get uploaded to has an element for a user_id. This is needed so that users can only view their records.

I'm able to get the records uploaded but I am having some fun and games around the user element.

At the moment, the records are being stored with a user element of 0 instead of the user's actual id.

Using the below code in 'Import PHP code' I can see that the user_id element is set as I would expect (eg the user's id), but then when it actually gets saved it is 0. It seems to be disappearing....

Code:
$listModel = $this->getModel();
$formModel = $listModel->getFormModel();
 
var_dump($formModel->formData);exit;

I've tried manually writing in the user's id using the below code, but it doesn't make a difference. It still saves as 0.
Code:
$formModel->formData['app_animal___user_id'] = $userid;

Any bright ideas as to what is going on? Its driving me a bit nuts... :eek:

Thanks,

Hannah
 
Wonderful, thanks Hugh! :D I've just uploaded the new version and a quick play shows the user fields are saving as expected.

I've a lot more testing and revisions to do to the CSV import stuff over the next couple of days, so I'll keep this thread open until I've played some more.

Thanks again for looking at this so swiftly and over the weekend as well! x
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top