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 #518
    The 518th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 13 April 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH