I am sending through a form object to Google Apps Script with:
var formObject = $("#my_form")[0];
google.script.run.processForm(formObject)
The form includes a file input and I have no problem retrieving this and the other input values on the server with something like:
function processForm(formObject) {
var user_name = formObject.userNameInputName;
}
The documentation is clear that GAS can send through a form providing it is the only parameter:
https://developers.google.com/apps-script/guides/html/reference/run#myFunction(...)
My question is:
How do I access a data attribute value of a form input server side?
And to answer this I need to ask a silly question:
What is a "form object"? What is it's structure, what does it "look like" - is it just a JavaScript object or something else? (if I console.log(formObject)
client side it just displays the HTML). If I know this I figure I will know how to access the data attribute value correctly.
Edit:
I ended up just adding a hidden input field to the form and setting the val()
of it via an on click event before submitting the form, then I could access the value server side with:
function processForm(formObject) {
var user_name = formObject.userNameInputName;
var was_a_data_attribute = formObject.myHiddenInputField;
}