Skip to content

Conversation

@NReib
Copy link

@NReib NReib commented Sep 5, 2025

Currently if an fx-action is added to a button within a form, the button is not used as the form's submitter and will not be included in the formdata.

This checks if the triggering element is a valid submitter and includes it into the formdata if so.

In this example when clicking the button, butName=butVal will not be included in the formdata, since it is no proper submit (fx-trigger defaults to click) and thus does not have a submitter.

<!DOCTYPE html>
<html>
	
<head>
	<script src="https://cdn.jsdelivr.net/gh/bigskysoftware/[email protected]/fixi.js"
        crossorigin="anonymous"
        integrity="sha256-0957yKwrGW4niRASx0/UxJxBY/xBhYK63vDCnTF7hH4="></script>

	<script>
	document.addEventListener('fx:before', function beforeFetch(evt,cfg) {
		for(const key of evt.detail.cfg.body.keys()){ 
			console.log(key);
		}
});
	</script>
</head>
<body>
	<form>
		<input type="hidden" name="hidName" value="hidVal"/>
		<button fx-action="/index.php" fx-method="POST" fx-target="#output" fx-swap="innerHTML" name="butName" value="butVal">Click here</button>
	</form>
	<div id="output">
		
	</div>
</body>
</html>

…vent

Currently if an fx-action is added to a button within a form, the form is not recognized as the form's submitter and will not be included in the formdata.

This checks if the triggering element is a valid submitter and includes it into the formdata if so.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant