Skip to content

Instantly share code, notes, and snippets.

@wizonesolutions
Forked from rocketeerbkw/gist:1591483
Created May 11, 2012 06:44
Show Gist options
  • Select an option

  • Save wizonesolutions/2657961 to your computer and use it in GitHub Desktop.

Select an option

Save wizonesolutions/2657961 to your computer and use it in GitHub Desktop.

Revisions

  1. @rocketeerbkw rocketeerbkw created this gist Jan 10, 2012.
    66 changes: 66 additions & 0 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@
    <?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));
    }