You are here

public function Submission::valueByKey in Little helpers 7

Same name and namespace in other branches
  1. 7.2 src/Webform/Submission.php \Drupal\little_helpers\Webform\Submission::valueByKey()

Retrieve a single value by a component's form_key.

Parameters

string $form_key: The form_key to look for.

Return value

mixed A value if possible or NULL otherwise.

File

src/Webform/Submission.php, line 90

Class

Submission
A useful wrapper for webform submission objects.

Namespace

Drupal\little_helpers\Webform

Code

public function valueByKey($form_key) {
  if ($component =& $this->webform
    ->componentByKey($form_key)) {
    return $this
      ->valueByCid($component['cid']);
  }
  elseif (isset($this->submission->tracking->{$form_key})) {
    return $this->submission->tracking->{$form_key};
  }
}