Skip to content
🚀 Rapid Application Development with the App Builder

preFormSubmit

Use the preFormSubmit hook to add custom validation checks or actions.

Parameters

ParameterTypeDescription
modeenumINSERT | UPDATE | VIEW
getColumnValuefunctionSee getColumnValue(columnName)
setValidationErrorfunctionSee setValidationError(columnName, errorMessage)
unsetValidationErrorfunctionSee unsetValidationError(columnName)

Return Value

Return false to cancel submit, true to proceed.

✨ Example Prevent Update with Custom Validation Error

js
((mode, getColumnValue, setValidationError, unsetValidationError) => {

	const error = "Customer 103 cannot be updated!"
	const customerNumber = getColumnValue("customerNumber")

	if (customerNumber == 103) {
		// Set validation error
		setValidationError("customerNumber", error)
	} else {
		// Don't forget to reset!
		unsetValidationError("customerNumber")
	}

})

Output

WP Data Access - Prevent Update with Custom Validation Error

✨ Example Prevent Update with Custom Behavior

js
((mode, getColumnValue, setValidationError, unsetValidationError) => {

	const error = "Customer 103 cannot be updated!"
	const customerNumber = getColumnValue("customerNumber")

	if (customerNumber == 103) {
		// Use built-in alert box
		wpda.alert("Form submit cancelled", error)
		return false
	}

})

Output

WP Data Access - Prevent Update with Custom Behavior