InputfieldForm::isSubmitted() method

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

NameType(s)Description
submitName (optional)string, Inputfield, bool

Any one of the following:

  • Name (string) or Inputfield (object) of submit button or other input to check.
  • Boolean true to find and return the clicked submit button name.
  • Boolean false or omit to only return true or false if form submitted (default).

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.244

Latest news

  • ProcessWire Weekly #559
    The 559th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 25 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

I just love the easy and intuitive ProcessWire API. ProcessWire rocks!” —Jens Martsch, Web developer