function gffd_get_purchase_field_requirements($as_object_or_gffd_index = false, $as_object = false) { $fields = array(array('gffd_index' => 'gffd_fd_cc_firstname', 'label' => __('Name'), 'meta' => __("Usually called <strong>Credit Card (Cardholder's Name)</strong>"), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_card_fields'); }, 'validate_pre_format' => function ($value) { if ($value != '') { return $value; } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_type', 'label' => __('Credit Card Type'), 'meta' => __('Usually called <strong>Credit Card (Card Type)</strong>'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_card_fields'); }, 'validate_pre_format' => function ($value) { // Right now the value that is selected from the form // feed setup does not work because GF does not send // the cc type when it's submitted like you would think. // // So, gffd-gf-forms.js should give us a // $_REQUEST['gffd_cc_type'] if (gffd_request('gffd_cc_type')) { return gffd_request('gffd_cc_type'); } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_number', 'label' => __('Credit Card Number'), 'meta' => __('Usually called <strong>Credit Card (Card Number)</strong>'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_card_fields'); }, 'validate_pre_format' => function ($value) { if ($value != '') { return $value; } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_exp', 'label' => __('Card Expiration Date'), 'meta' => __('Usually called <strong>Credit Card (Expiration Date)</strong>'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_card_fields'); }, 'validate_pre_format' => function ($value) { if (is_array($value)) { // The value (when submitted by $_POST) // is an array: // // array(2) { [0]=> string(1) "1" [1]=> string(4) "2016" } // // So, let's chop those two array // structs into a value that is good for FD. if (isset($value[0]) && isset($value[1])) { return str_pad($value[0], 2, '0', STR_PAD_LEFT) . substr($value[1], -2); } else { return false; } } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_cvv', 'label' => __('CVV/Security Code'), 'meta' => __('Usually called <strong>Credit Card (Security Code)</strong>'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_card_fields'); }, 'validate_pre_format' => function ($value) { if ($value != '') { return $value; } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_amount', 'label' => __('Charge Amount'), 'meta' => __('Here you will need to select a <strong>' . 'total field</strong> to your form'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_card_fields'); }, 'validate_pre_format' => function ($value) { if ($value != '') { return str_replace("\$", "", $value); } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_address', 'label' => __('Address'), 'meta' => gffd_language_terms('you_will_need_address_field_select_here'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_address'); }, 'validate_pre_format' => function ($value) { if ($value != '') { return $value; } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_address2', 'label' => __('Address2'), 'meta' => gffd_language_terms('you_will_need_address_field_select_here'), 'validate_bad_message' => function () { return true; }, 'validate_pre_format' => function ($value) { return true; }), array('gffd_index' => 'gffd_fd_cc_zip', 'label' => __('Zip'), 'meta' => gffd_language_terms('you_will_need_address_field_select_here'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_address'); }, 'validate_pre_format' => function ($value) { if ($value != '') { return $value; } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_city', 'label' => __('City'), 'meta' => gffd_language_terms('you_will_need_address_field_select_here'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_address'); }, 'validate_pre_format' => function ($value) { if ($value != '') { return $value; } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_state', 'label' => __('State'), 'meta' => gffd_language_terms('you_will_need_address_field_select_here'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_address'); }, 'validate_pre_format' => function ($value) { if ($value != '') { return $value; } else { return false; } }), array('gffd_index' => 'gffd_fd_cc_country', 'label' => __('Country'), 'meta' => gffd_language_terms('you_will_need_address_field_select_here'), 'validate_bad_message' => function () { return gffd_language_terms('term_validate_bad_message_most_address'); }, 'validate_pre_format' => function ($value) { if ($value != '') { return $value; } else { return "US"; } })); // If they ask for 'gffd_fd_cc_zip' or 'as_object' if (is_string($as_object_or_gffd_index)) { // If it is 'as_object' if ($as_object_or_gffd_index == 'as_object') { return gffd_array_as_object($fields); // If it's not 'as_object', let's assume // it's a gffd_index. } else { //Pull out just the field they are asking for. foreach ($fields as $field) { if ($field['gffd_index'] == $as_object_or_gffd_index) { $_the_field = $field; } } // If they also said, 'gffd_fd_cc_zip', 'as_object', // return as an object. if ($as_object) { return gffd_array_as_object($_the_field); // If they just said 'gffd_fd_cc_zip' then return // it as an array } else { return $_the_field; } } // If they pass (true), then just pass as an // object. } elseif ($as_object_or_gffd_index == true) { return gffd_array_as_object($fields); // If they just pass () then return // as an array. } else { return $fields; } }
echo $required_field['gffd_index']; ?> " name="gffd_form_feed_indexes[<?php echo $required_field['gffd_index']; ?> ]" style="width:300px;"> <option value=""><?php _e("Choose a source for this data"); ?> </option> <option value="">--</option> <?php foreach (gffd_is_array(gffd_get_form_fields(gffd_get_form(gffd_request('form_id')))) as $form_field) { ?> <option <?php if (is_object(gffd_feeds_get_form_feed_settings(gffd_request('form_id'), 'as_object')->feed_indexes) && gffd_feeds_get_form_feed_settings(gffd_request('form_id'), 'as_object')->feed_indexes->{$required_field}['gffd_index'] == $form_field[0]) { ?> selected="selected" <?php } ?> value="<?php echo $form_field[0]; ?> "><?php echo $form_field[1]; ?> </option> <?php } ?>