You are here

function commerce_paypal_checkout_customize_buttons_validate in Commerce PayPal 7.2

Element validate callback for the customize_buttons payment method setting.

1 string reference to 'commerce_paypal_checkout_customize_buttons_validate'
commerce_paypal_checkout_settings_form in modules/checkout/commerce_paypal_checkout.module
Payment method callback: settings form.

File

modules/checkout/commerce_paypal_checkout.module, line 447
Implements PayPal Checkout in Drupal Commerce checkout.

Code

function commerce_paypal_checkout_customize_buttons_validate($element, &$form_state, $form) {

  // Make sure no style is saved when the the "customize_buttons" checkbox
  // is unchecked.
  $parents = $element['#parents'];
  array_pop($parents);
  $parents[] = 'style';
  if (empty($element['#value'])) {
    drupal_array_set_nested_value($form_state['values'], $parents, array(), TRUE);
  }
  else {
    $style = drupal_array_get_nested_value($form_state['values'], $parents);

    // The tagline is not allowed for the vertical layout.
    if ($style['layout'] == 'vertical') {
      unset($style['tagline']);
      drupal_array_set_nested_value($form_state['values'], $parents, $style, TRUE);
    }
  }
}