You are here

public function Checkboxes::getElementSelectorInputValue in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/Checkboxes.php \Drupal\webform\Plugin\WebformElement\Checkboxes::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 OptionsBase::getElementSelectorInputValue

1 method overrides Checkboxes::getElementSelectorInputValue()
WebformCheckboxesOther::getElementSelectorInputValue in src/Plugin/WebformElement/WebformCheckboxesOther.php
Get an element's (sub)input selector value.

File

src/Plugin/WebformElement/Checkboxes.php, line 151

Class

Checkboxes
Provides a 'checkboxes' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function getElementSelectorInputValue($selector, $trigger, array $element, WebformSubmissionInterface $webform_submission) {
  $input_name = WebformSubmissionConditionsValidator::getSelectorInputName($selector);
  $option_value = WebformSubmissionConditionsValidator::getInputNameAsArray($input_name, 1);
  $value = $this
    ->getRawValue($element, $webform_submission) ?: [];
  if (in_array($option_value, $value, TRUE)) {
    return in_array($trigger, [
      'checked',
      'unchecked',
    ]) ? TRUE : $value;
  }
  else {
    return in_array($trigger, [
      'checked',
      'unchecked',
    ]) ? FALSE : NULL;
  }
}