function constant_contact_signup_form in Constant Contact 6.2
Same name and namespace in other branches
- 6.3 constant_contact.module \constant_contact_signup_form()
- 7.3 constant_contact.module \constant_contact_signup_form()
Shows the custom signup form, added using a block
1 string reference to 'constant_contact_signup_form'
- constant_contact_block in ./
constant_contact.module - Enables us to add a custom signup form using a block
File
- ./
constant_contact.module, line 589
Code
function constant_contact_signup_form(&$form_state) {
$cc = constant_contact_create_object();
if (!$cc) {
return;
}
$form = array();
$show_firstname = variable_get('constant_contact_show_firstname', CONSTANT_CONTACT_SHOW_FIRSTNAME);
$show_lastname = variable_get('constant_contact_show_lastname', CONSTANT_CONTACT_SHOW_LASTNAME);
$show_job_title = variable_get('constant_contact_show_job_title', CONSTANT_CONTACT_SHOW_JOB_TITLE);
$show_company_name = variable_get('constant_contact_show_company_name', CONSTANT_CONTACT_SHOW_COMPANY_NAME);
$show_lists_selection = variable_get('constant_contact_show_list_selection', CONSTANT_CONTACT_SHOW_LIST_SELECTION);
if ($show_firstname) {
$form['cc_firstname'] = array(
'#type' => 'textfield',
'#title' => t('Firstname'),
'#size' => 30,
'#required' => TRUE,
'#default_value' => $form_state['values']['cc_firstname'],
);
}
if ($show_lastname) {
$form['cc_lastname'] = array(
'#type' => 'textfield',
'#title' => t('Lastname'),
'#size' => 30,
'#required' => TRUE,
'#default_value' => $form_state['values']['cc_lastname'],
);
}
if ($show_company_name) {
$form['cc_company_name'] = array(
'#type' => 'textfield',
'#title' => t('Company Name'),
'#size' => 30,
'#required' => TRUE,
'#default_value' => $form_state['values']['cc_company_name'],
);
}
if ($show_job_title) {
$form['cc_job_title'] = array(
'#type' => 'textfield',
'#title' => t('Job Title'),
'#size' => 30,
'#required' => TRUE,
'#default_value' => $form_state['values']['cc_job_title'],
);
}
$form['cc_email'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#size' => 30,
'#required' => TRUE,
);
if ($show_lists_selection) {
$exclude_lists = variable_get('constant_contact_lists', '');
$lists = $cc
->get_lists();
if ($lists) {
foreach ($lists as $k => $v) {
$lists[$k] = $v['id'];
}
}
if (!is_array($exclude_lists)) {
$exclude_lists = array();
}
$options = array();
foreach ($lists as $list_id) {
if (!in_array($list_id, $exclude_lists)) {
$list = $cc
->get_list($list_id);
$options[$list['id']] = $list['Name'];
}
}
if (count($options) > 0) {
$form['cc_newsletter_lists'] = array(
'#type' => 'select',
'#description' => variable_get('constant_contact_signup_lists_description', CONSTANT_CONTACT_SIGNUP_LISTS_DESCRIPTION),
'#options' => $options,
'#multiple' => true,
'#size' => count($options),
);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Signup'),
);
return $form;
}