Closed (fixed)
Project:
Webform
Version:
6.x-2.9
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Jul 2010 at 12:16 UTC
Updated:
16 Aug 2010 at 15:50 UTC
There is a way to find out the UID of the user who is editing the form ?
My form have a hidden field with the token: %profile[profile_fullname]
So...I know who submited the form, but after that another person edit the same form, and the field above remains with the first user who created the form...
To workaround this situation, I have created an dynamic_field with the following:
$result = db_query("SELECT users.uid AS uid, profile_values_profile_fullname.value AS profile_values_profile_fullname_value
FROM users users LEFT JOIN profile_values profile_values_profile_fullname ON users.uid = profile_values_profile_fullname.uid AND profile_values_profile_fullname.fid = '2' ORDER BY profile_values_profile_fullname_value ASC");
$arr = array();
while ($record = db_fetch_array($result)) {
$arr[check_plain($record['profile_values_profile_fullname_value'])] = check_plain($record['profile_values_profile_fullname_value']);
}
return $arr;
This is returning obviously an select field with all site users name.
Certainly this is not the best way, I need to get this user automatically.
Please, someone could help me ?
Comments
Comment #1
rsacchi commentedIn the situation above when a user is editing the form, he needs to pick up their username from the list generated from dynamic_field...
Comment #2
quicksketchI would suggest using the 3.x version and using the hook_webform_select_options() hook to provide a dynamic select list with $uid => $username keys. Then set the default value of the form to %uid in the webform setting. However this still probably won't automatically-update when users update the submission. You may need to use hook_form_alter() in a custom module to get such functionality.
Comment #3
rsacchi commentedQuicksketch thanks again for your support and patience.
I'am completly disoriented, could you please gime me the ideia on how to do that?
As I know I need to create a module with some code, like:
And then how pass it to the webform module ?
Comment #4
quicksketchI don't provide support on how to write custom code in the Webform queue. If you find a solution feel free to post it here for others.