You are here

public function WebformHeight::getElementSelectorInputValue in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/WebformHeight.php \Drupal\webform\Plugin\WebformElement\WebformHeight::getElementSelectorInputValue()

Get an element's (sub)input selector value.

Parameters

string $selector: CSS :input selector.

string $trigger: Trigger from #states.

array $element: An element.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

Return value

mixed The element input's value.

Overrides WebformElementBase::getElementSelectorInputValue

File

src/Plugin/WebformElement/WebformHeight.php, line 159

Class

WebformHeight
Provides a 'height' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function getElementSelectorInputValue($selector, $trigger, array $element, WebformSubmissionInterface $webform_submission) {
  $value = $this
    ->getRawValue($element, $webform_submission);
  if (empty($value)) {
    return NULL;
  }
  $input_name = WebformSubmissionConditionsValidator::getSelectorInputName($selector);
  $part = WebformSubmissionConditionsValidator::getInputNameAsArray($input_name, 1);
  $value = (double) $value;
  $feet = floor($value / 12);
  $inches = $value - $feet * 12;
  switch ($part) {
    case 'feet':
      return $feet;
    case 'inches':
      return $inches;
    default:
      return NULL;
  }
}