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

Twitter updates

  • Adding custom actions to ProcessWire image fields in the admin, part of this week’s dev branch additions: More
    27 January 2023
  • ProcessWire 3.0.210 new main/master version released— More
    6 January 2023
  • ProcessWire 3.0.209: Core updates and an interesting AI that knows ProcessWire– More
    30 December 2022

Latest news

  • ProcessWire Weekly #456
    The 456th issue of ProcessWire Weekly covers latest core updates, introduces a new third party module called TextformatterRockDown, and more. Read on!
    Weekly.pw / 4 February 2023
  • ProcessWire 3.0.210 new main/master version
    140 commits, 55 resolved issues, dozens of new features, eight contributors, and five new pull requests make yet another great new version of ProcessWire.
    Blog / 6 January 2023
  • Subscribe to weekly ProcessWire news

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