You are here

public static function WebformSubmissionConditionsValidator::getInputNameAsArray in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionConditionsValidator.php \Drupal\webform\WebformSubmissionConditionsValidator::getInputNameAsArray()

Parse input name which can container nested elements defined using #tree.

Converts 'input[subkey]' into ['input', 'subkey'].

Parameters

string $name: The input name.

int $index: A specific input name index to be returned.

Return value

array|string An array containing the input name and keys or specific input name.

See also

http://php.net/manual/en/faq.html.php#faq.html.arrays

10 calls to WebformSubmissionConditionsValidator::getInputNameAsArray()
Checkboxes::getElementSelectorInputValue in src/Plugin/WebformElement/Checkboxes.php
Get an element's (sub)input selector value.
DateList::getElementSelectorInputValue in src/Plugin/WebformElement/DateList.php
Get an element's (sub)input selector value.
DateTime::getElementSelectorInputValue in src/Plugin/WebformElement/DateTime.php
Get an element's (sub)input selector value.
OptionsBase::getElementSelectorInputValue in src/Plugin/WebformElement/OptionsBase.php
Get an element's (sub)input selector value.
WebformCheckboxesOther::getElementSelectorInputValue in src/Plugin/WebformElement/WebformCheckboxesOther.php
Get an element's (sub)input selector value.

... See full list

File

src/WebformSubmissionConditionsValidator.php, line 1130

Class

WebformSubmissionConditionsValidator
Webform submission conditions (#states) validator.

Namespace

Drupal\webform

Code

public static function getInputNameAsArray($name, $index = NULL) {
  $name = str_replace([
    '][',
    '[',
    ']',
  ], [
    '|',
    '|',
    '',
  ], $name);
  $array = explode('|', $name);
  if ($index !== NULL) {
    return isset($array[$index]) ? $array[$index] : NULL;
  }
  else {
    return $array;
  }
}