Created
January 10, 2012 22:06
-
-
Save rocketeerbkw/1591483 to your computer and use it in GitHub Desktop.
Test Drupal FAPI does not receive date when name attribute is removed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function stripe_test_menu() { | |
$items = array(); | |
$items['stripe-test'] = array( | |
'title' => t('Stripe Test'), | |
'page callback' => 'drupal_get_form', | |
'page arguments' => array('stripe_test_form'), | |
'access callback' => TRUE, | |
); | |
return $items; | |
} | |
function stripe_test_form($form, &$form_state) { | |
$js = <<<EJS | |
jQuery(function() { | |
jQuery('#edit-remove-names').click(function() { | |
var check = jQuery(this); | |
check.attr('disabled', 'disabled'); | |
jQuery(':text').removeAttr('name'); | |
}) | |
}) | |
EJS; | |
drupal_add_js($js, 'inline'); | |
$form['card-number'] = array( | |
'#type' => 'textfield', | |
'#title' => t('Credit Card Number'), | |
); | |
$form['card-exp'] = array( | |
'#type' => 'fieldset', | |
'#title' => t('Card Expiration'), | |
); | |
$form['card-exp']['month'] = array( | |
'#type' => 'textfield', | |
'#title' => t('Month'), | |
); | |
$form['card-exp']['year'] = array( | |
'#type' => 'textfield', | |
'#title' => t('Year'), | |
); | |
$form['remove-names'] = array( | |
'#type' => 'checkbox', | |
'#title' => 'Remove name attributes', | |
); | |
$form['submit'] = array( | |
'#type' => 'submit', | |
'#value' => t('Save'), | |
); | |
return $form; | |
} | |
function stripe_test_form_submit($form, &$form_state) { | |
drupal_set_message(print_r($form_state['values'], true)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment