How to preload Form with previous stored data (from the same user)

Ghuerren

Member
Hi there!
I found this link, which covers almost what i need.

http://fabrikar.com/forums/index.ph...-field-with-data-from-a-previos-record.21407/

But as i`m not and php coder, i was wondering if anyone could help me on my problem.
I have a big form (40 elements) that should be filled daily by many users.
The problem is that each element is basically a 10 digit number that almost never change. But each user has a different number for each element. So i can use a standart number for everybody.
The ideal would be to preload the form each time the user try to fill it with the HIS last saved data (i mean, the last saved data from the same logged in user)
Is that possible? How?

1- Wich code should i use?
2- Where should i put it (all elements of the form, or is there a way to preload all elements at once?)?
Tx a lot!
 
Tx for the answer but i think there was i misunderstanding. Maybe i was not clear enough
What i need is that the form preloads the data dynamically for each user, using each one`s last saved data.
So, a single default value for all each element does not resolve my problem.

The example would be like this.

element_1 (number) should be 100089097123 for user X and 1000897631236 for user Y

element_2 (date) should be 03-04-2009 for user X and 03-05-2010 for user Y

and so on...

Note that i have more than 40 elements and 50 users....

Tx a lot for your help!
 
This is what the php code is for.
determine user,
select fields1,2,3-you-need from your-table where record-is-belonging-to-user and it's-the-lastest-record-of-this-user
set element1 = field1, element2 = field2 etc
 
Oh my! Have no idea how to do it. :(
Where do i start looking?
:)
Tx.
Sorry for my low knowledge level in coding...
 
Well, i manage a way to retrieve data from user`s latest record. Brutal force....
But not all the fields at once, as u suggested.
I achieved that by editing every element of the form :)eek:).
Element -> details -> options -> Standard

Code:
$user = JFactory::getUser();
$userid = $user->get('id');
$db = JFactory::getDBO();
$db->setQuery("SELECT put_the_name_of_your_field_here FROM put_the_name_of_your_table_here WHERE user_name = '$userid' ORDER BY id DESC LIMIT 1");
return $db->loadResult();

Also checked the Eval to Yes

So that would be kind of :confused: to adapt it to every element i have.

Can you trick the code so i use it at the form php field, please?

Tx a lot.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top