You are here

public static function WebformElementHelper::isType in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Utility/WebformElementHelper.php \Drupal\webform\Utility\WebformElementHelper::isType()

Determine if a webform element is a specified #type.

Parameters

array $element: A webform element.

string|array $type: An element type.

Return value

bool TRUE if a webform element is a specified #type.

4 calls to WebformElementHelper::isType()
WebformActions::processWebformActions in src/Element/WebformActions.php
Processes a form actions container element.
WebformAjaxFormTrait::buildAjaxForm in src/Form/WebformAjaxFormTrait.php
Add Ajax support to a form.
webform_bootstrap_preprocess_form_element in modules/webform_bootstrap/webform_bootstrap.module
Implements hook_preprocess_form_element() for form element templates.
_captcha_webform_submission_form_after_build in third_party_settings/webform.captcha.inc
After build callback to add warning to CAPTCHA placement.

File

src/Utility/WebformElementHelper.php, line 169

Class

WebformElementHelper
Helper class webform element methods.

Namespace

Drupal\webform\Utility

Code

public static function isType(array $element, $type) {
  if (!isset($element['#type'])) {
    return FALSE;
  }
  if (is_array($type)) {
    return in_array($element['#type'], $type);
  }
  else {
    return $element['#type'] === $type;
  }
}