Is form submitted and ready to process?
- Optionally use this method to test if form is submitted before calling processInput().
- Specify the submit button name to confirm that was the button used to submit.
- Returns the name of the submit button used when form is submitted, false otherwise.
- If no arguments specified, requires that the form has one or more InputfieldSubmit fields.
- Like with processInput(), make sure form is fully built before calling this.
- If given $submitName argument that corresponds to InputfieldSubmit field then it will also be confirmed that the input value matches the field value prior to submit.
- If given a $submitName argument that corresponds to some other Inputfield type then only its presence in the input will be confirmed.
Available since version 3.0.205.
Example
if($form->isSubmitted()) {
// form was submitted
}
// specify the button name to confirm it was used to submit the form
if($form->isSubmitted('submit_save')) {
// form is submitted with button named 'submit_save'
}
// omit button name to have it return button name used to submit
$submit = $form->isSubmitted(true);
if($submit === 'add') {
// form was submitted with button named 'add'
} else if($submit === 'save') {
// form submitted with button named 'save'
} else if($submit === false) {
// form not submitted
} else {
// submitted using some other button (name in $submit)
}
Usage
// basic usage
$bool = $inputfieldForm->isSubmitted();
// usage with all arguments
$bool = $inputfieldForm->isSubmitted($submitName = '');
Arguments
Name | Type(s) | Description |
---|---|---|
submitName (optional) | string, Inputfield, bool | Any one of the following:
|
Return value
bool
string
Returns one of the following:
- Boolean false if form not submitted.
- Boolean true if form submitted and submit button name not requested.
- Submit/input name (string) if form submitted and
$submitName
argument is true or string.
Exceptions
Method can throw exceptions on error:
WireException
InputfieldForm methods and properties
API reference based on ProcessWire core version 3.0.236