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

Latest news

  • ProcessWire Weekly #550
    In the 550th issue of ProcessWire Weekly we're going to check out the latest core updates, introduce a new third party module called PagefileMetadata, and more. Read on!
    Weekly.pw / 23 November 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“ProcessWire is like a breath of fresh air. So powerful yet simple to build with and customise, and web editors love it too.” —Margaret Chatwin, Web developer