You are here

public static function MobileNumber::getOp in Mobile Number 8

Same name and namespace in other branches
  1. 2.0.x src/Element/MobileNumber.php \Drupal\mobile_number\Element\MobileNumber::getOp()

Get mobile number form operation name based on the button pressed in the form.

Parameters

array $element: Mobile number element.

\Drupal\Core\Form\FormStateInterface $form_state: Form state.

Return value

null|string Operation name, or null if button does not belong to element.

4 calls to MobileNumber::getOp()
MobileNumber::mobileNumberProcess in src/Element/MobileNumber.php
Mobile number element process callback.
MobileNumber::mobileNumberValidate in src/Element/MobileNumber.php
Mobile number element validate callback.
MobileNumber::verifyAjax in src/Element/MobileNumber.php
Mobile number element ajax callback.
MobileNumberWidget::errorElement in src/Plugin/Field/FieldWidget/MobileNumberWidget.php
Assigns a field-level validation error to the right widget sub-element.

File

src/Element/MobileNumber.php, line 468

Class

MobileNumber
Provides a form input element for entering an email address.

Namespace

Drupal\mobile_number\Element

Code

public static function getOp(array $element, FormStateInterface $form_state) {
  $triggering_element = $form_state
    ->getTriggeringElement();
  $op = !empty($triggering_element['#mobile_number_op']) ? $triggering_element['#mobile_number_op'] : NULL;
  $button = !empty($triggering_element['#name']) ? $triggering_element['#name'] : NULL;
  if (!in_array($button, [
    implode('__', $element['#parents']) . '__send_verification',
    implode('__', $element['#parents']) . '__verify',
  ])) {
    $op = NULL;
  }
  return $op;
}