Forum:SMW/SF - how can I preload/default a field to contain the name of the user filling in the (partial) form

Extension:Semantic forms has the

feature however I have learned that this inserts the name of the user who initially created the page being edited with the current form.

I want to be able to automatically insert the name of whichever user is presently interfacing with a (full or partial) form to edit data on a pre-existing page. The form might be the default form, an alternate form or a partial form - it should not matter.

I have experimented with the deprecated Template:USERNAME and the associated UserNameReplace javascript (which uses YUI and not jQuery) however I am not able to make that evaluate and populate a semantic form. Complicating the matter is my desire to treat that input field as hidden. ie. populated but without the user being free to view or edit the username automatically entered into that field.

The nearest workaround I can come up with so far is to tag all user pages with  and then provide a partial form that serves up a dropdown style input box with all names belonging to that category. viz.

It's clumsy and I'd prefer the user not be aware of other user's names while using the form I have in mind for this. najevi 20:24, 18 July 2009 (UTC)

Javascript solution
With thanks to Dantman and Ciencia_al_Poder I now have the following script correctly inserting the current user name into a specific input field of input type text or dropdown but not radiobutton and I have not yet tried listbox.

function preloadThisUserName { $("#bodyContent form.createbox") /* narrows the search */ .find("input[name$='[Thisuser]']") /* affects _any_ template with a parameter/field named: Thisuser */ .val(wgUserName); /* Checks, or selects, all the radio buttons, checkboxes, and select options that match the user name. */ $("#bodyContent form.createbox") .find("select[name$='[Thisuser]']") .val(wgUserName); /* Checks, or selects, all the radio buttons, checkboxes, and select options that match the user name. */ }

$( preloadThisUserName );

The semantic form's template must used the named parameter Thisuser to allow this script to identify the input field by name. Note: wgUserName is case-sensitive. -najevi 09:03, 22 July 2009 (UTC)


 * To add a radio button, this should work:

$("#bodyContent form.createbox") /* narrows the search */ .find("input[name$='[Thisuser]'][value='"+wgUserName+"']:radio").attr("checked","checked");
 * --Ciencia Al Poder (talk) -WikiDex 10:39, 26 July 2009 (UTC)