fileupload element - ajax enabled - rename file

wuschel_lux

Member
Good morning,

I am struggling with renaming my files when activating AJAX.
Without AJAX my code is working properly and takes the JUSER_ID from the actual form
PHP:
$myJuser = $formModel->getElementData('tablename___juser_id');
$myJuser = $myJuser[0];
With the JUSER_ID, I do some DB queries to get a unique number, first - and last name. With the return I bild the filename:
unique number_first - and last name_10randChars.ext

When using AJAX I read in the forum that some but not all and the $formModel-> will not be available. But is there maybe an other way to get the ID value from the form?

Thanks again for your help
 
Is the user id the id of the logged in user?

Fetch it with the Fabrik placeholder '{$my->id}' or with Joomla's $userId = JFactory::getUser()->id;
 
not really...
the customer registers to an event, but an "admin" can modify or complete the request, so it must be the initial Joomla user id from this record
 
thanks for your help.
yes thats the problem with AJAX upload I cannot access the data model. But without AJAX, when an validation in the big form fails, the uploads are gone and need to be attached again (I know, not a Fabrikar fault), this provoked a lot of complaints :-(

in 3 cases the JUSER_ID must be fetched:
- on a new record (user initiated)
- on edit (user initiated)
- on edit ("admin" initiated)
and must get always the initial user JUSER_ID.
 
On a new record '{$my->id}' or JFactory::getUser()->id; should do (assuming only the logged in user can create a new record).
On edit you must fetch it from the recorded data.
I assume it is somewhere in $formModel->xy or $data[] or $this->xy (try with what is mentioned is the php-plugin)
If really nothing is accessible you can at least get it directly from the database using the rowid.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top