function _webform_edit_paypal in Webform Paypal 7.2
Same name and namespace in other branches
- 7 webform_paypal.module \_webform_edit_paypal()
Generate the form for editing a component. When someone builds a Webform, the first step is to add a component to the form. Next, they have to edit the settings for the component that they just added. This function, then, allows you to define the settings that appear on that "edit component" page.
File
- ./
webform_paypal.module, line 63
Code
function _webform_edit_paypal($component) {
$form = array();
$form['value'] = array(
'#title' => t('Paypal Button ID'),
'#type' => 'textfield',
'#required' => TRUE,
'#default_value' => $component['value'],
'#element_validate' => array(
'_webform_edit_paypal_validate',
),
'#description' => "The id of the button generated within your Paypal account. This can be found by visiting Merchant Services > My Saved Buttons or by copying the value for 'hosted-button-id' in the button code provided by Paypal",
);
if (user_access('use paypal sandbox')) {
$form['paypal'] = array(
'#type' => 'fieldset',
'#title' => t('Development Settings'),
);
$form['paypal']['transaction'] = array(
"#type" => 'select',
'#title' => t('Choose the type of transaction to process.'),
'#options' => array(
'live' => 'Live Transaction',
'testing' => 'Testing/Sandbox',
),
'#description' => t('In order to use "Testing/Sandbox", you must have a <a href="https://developer.paypal.com/">developer account</a> set up with PayPal.'),
'#default_value' => $component['extra']['transaction'],
'#parents' => array(
'extra',
'transaction',
),
);
}
//12 lines to avoid 3 notices when first adding component. See Issue #1408658
$type = '';
$style = '';
$language = '';
if (!empty($component['extra']['type'])) {
$type = $component['extra']['type'];
}
if (!empty($component['extra']['style'])) {
$style = $component['extra']['style'];
}
if (!empty($component['extra']['language'])) {
$language = $component['extra']['language'];
}
$form['extra']['type'] = array(
'#title' => t('Button Type'),
'#type' => 'select',
'#options' => array(
'btn_cart' => 'Shopping Cart',
'btn_buynow' => 'Buy Now',
'btn_donate' => 'Donation',
'btn_git' => 'Gift Certificate',
'btn_subscribe' => 'Subscribe',
),
'#required' => TRUE,
'#default_value' => $type,
);
$form['extra']['style'] = array(
'#title' => t('Button Style'),
'#type' => 'select',
'#options' => array(
'_SM' => 'Small',
'_LG' => 'Large',
'CC_LG' => 'Large with Credit Card logos',
),
'#required' => TRUE,
'#default_value' => $style,
);
$form['extra']['language'] = array(
'#title' => t('Button Language'),
'#type' => 'select',
'#options' => array(
'en_US' => 'English',
'es_ES' => 'Spanish',
'fr_FR' => 'French',
'it_IT' => 'Italian',
'de_DE' => 'German',
),
'#required' => TRUE,
//TODO:lookup if site has language value
'#default_value' => $language,
);
return $form;
}