Form Data Not in Scope for Fields Starting with “_”

I am encountering a strange issue when working with forms. When the field name starts with an underscore, the data that the form contains is not in the form scope. However, the field is still present in form.fieldnames.

Here is a dump of my form scope:

OS: Windows 11
Java Version: 17.0.6
Lucee Version: 5.3.10.120

I have read somewhere that form names are starting with underscore should be avoided. I saw that somewhere when having issues with dots in some form fieldnames (something we should also avoid). Best I can find for now is here:

So there is no apparent fix for my issue, for instance modifying the something in the config?

<cfscript>
    dump(server.lucee.version);
    src=fileRead(getCurrentTemplatePath());
</cfscript>

<cfoutput>
    <pre>#htmleditformat(src)#</pre>
</cfoutput>

<form action="?" method="POST">
    <input type="hidden" name="_one" value=1>
    <input type="hidden" name="one" value=1>
    
    <input type="submit">
</form>
<cfdump var=#form#>
1 Like

thanks
Then I’m guessing the issue has something to do with masa. I’ll just use js to get the data

A working example is always the best! If it works, it works! Thanks Zac!

Just for completeness, I found what I mentioned. It’s in the HTML4 specs:

https://www.w3.org/TR/html4/types.html#type-id

2 Likes

for anyone who ever encounters the same issue and stumbles across this:
I’ve managed to retrieve the data by renaming the form fields before submitting them using JQuery

	// gets form data because masa/mura ignores fields starting with _
	$('form').submit(function(event) {
		$('input[name="_mosparo_submitToken"]').attr('name', 'mosparo_submitToken');
		$('input[name="_mosparo_validationToken"]').attr('name', 'mosparo_validationToken');
		this.submit();
	});
1 Like