You are here

public function Braintree_Result_Error::valueForHtmlField in Commerce Braintree 7

return original value for a field For example, if a user tried to submit 'invalid-email' in the html field transaction[customer][email], $result->valueForHtmlField("transaction[customer][email]") would yield "invalid-email"

Parameters

string $field:

Return value

string

File

braintree_php/lib/Braintree/Result/Error.php, line 52

Class

Braintree_Result_Error
Braintree Error Result

Code

public function valueForHtmlField($field) {
  $pieces = preg_split("/[\\[\\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
  $params = $this->params;
  foreach (array_slice($pieces, 0, -1) as $key) {
    $params = $params[Braintree_Util::delimiterToCamelCase($key)];
  }
  $finalKey = Braintree_Util::delimiterToCamelCase(end($pieces));
  $fieldValue = isset($params[$finalKey]) ? $params[$finalKey] : null;
  return $fieldValue;
}