You are here

function commerce_stripe_set_addressfield_class_names in Commerce Stripe 7

Same name and namespace in other branches
  1. 7.3 commerce_stripe.module \commerce_stripe_set_addressfield_class_names()
  2. 7.2 commerce_stripe.module \commerce_stripe_set_addressfield_class_names()

Sets unique class names on address field form elements so that they can be picked up by commerce_stripe.js.

Parameters

$element: the addressfield form element

2 calls to commerce_stripe_set_addressfield_class_names()
commerce_stripe_cardonfile_create_form in ./commerce_stripe.module
Card on file callback: create form
commerce_stripe_field_widget_addressfield_standard_form_alter in ./commerce_stripe.module
Implements hook_field_widget_WIDGET_TYPE_form_alter() for addressfield.

File

./commerce_stripe.module, line 1160
This module provides Stripe (http://stripe.com/) payment gateway integration to Commerce. Commerce Stripe offers a PCI-compliant way to process payments straight from you Commerce shop.

Code

function commerce_stripe_set_addressfield_class_names(&$element) {
  if (isset($element['street_block']['thoroughfare'])) {
    $element['street_block']['thoroughfare']['#attributes']['class'][] = 'commerce-stripe-thoroughfare';
  }
  if (isset($element['street_block']['premise'])) {
    $element['street_block']['premise']['#attributes']['class'][] = 'commerce-stripe-premise';
  }
  if (isset($element['locality_block']['locality'])) {
    $element['locality_block']['locality']['#attributes']['class'][] = 'commerce-stripe-locality';
  }
  if (isset($element['locality_block']['administrative_area'])) {
    $element['locality_block']['administrative_area']['#attributes']['class'][] = 'commerce-stripe-administrative-area';
  }
  if (isset($element['locality_block']['postal_code'])) {
    $element['locality_block']['postal_code']['#attributes']['class'][] = 'commerce-stripe-postal-code';
  }
  if (isset($element['country'])) {
    $element['country']['#attributes']['class'][] = 'commerce-stripe-country';
  }
}