Appearance
preFormSubmit
Use the preFormSubmit hook to add custom validation checks or actions.
Parameters
| Parameter | Type | Description |
|---|---|---|
| mode | enum | INSERT | UPDATE | VIEW |
| getColumnValue | function | See getColumnValue(columnName) |
| setValidationError | function | See setValidationError(columnName, errorMessage) |
| unsetValidationError | function | See 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

✨ 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

