function webform_civicrm_configure_form_item in Webform CiviCRM Integration 6.2
Same name and namespace in other branches
- 7.2 webform_civicrm_admin.inc \webform_civicrm_configure_form_item()
Build a field item for the configure form
1 call to webform_civicrm_configure_form_item()
- webform_civicrm_configure_form_builder in ./
webform_civicrm_admin.inc - Form to configure CiviCRM options for a Webform Called indirectly from hook_menu() for D7-D6 compatibility
File
- ./
webform_civicrm_admin.inc, line 703
Code
function webform_civicrm_configure_form_item($fid, $field, $settings) {
$lists = webform_civicrm_get_fields('lists');
list($lobo, $c, $ent, $n, $table, $name) = explode('_', $fid, 6);
$field['name'] = str_replace('#', $table == 'relationship' ? $n : '', $field['name']);
// Create dropdown list
if (!empty($field['expose_list'])) {
// Retrieve option list
$options = array(
'create_civicrm_webform_element' => t('-user select-'),
);
if (!empty($field['empty_option'])) {
$options += array(
$field['empty_option'],
);
}
$field['form_key'] = $fid;
$options += webform_civicrm_field_options($field, 'config_form', $settings['data']);
$item = array(
'#type' => 'select',
'#title' => $field['name'],
'#options' => $options,
'#multiple' => !empty($field['extra']['multiple']),
'#default_value' => !empty($field['empty_option']) ? 0 : NULL,
);
if (isset($settings[$fid])) {
$item['#default_value'] = $settings[$fid];
}
elseif (isset($settings['data'][$ent][$c][$table][$n][$name])) {
$item['#default_value'] = $settings['data'][$ent][$c][$table][$n][$name];
}
elseif (empty($field['extra']['multiple'])) {
$options = array_keys($options);
$item['#default_value'] = $options[1];
}
if (!empty($field['extra']['multiple'])) {
$item['#description'] = t('You may set options here and/or add this element to the webform ("user select"). If you do both, options set here will not appear on the form.');
$item['#default_value'] = (array) $item['#default_value'];
if (isset($settings[$fid]) && !is_array($settings[$fid]) && isset($settings['data'][$ent][$c][$table][$n][$name])) {
$item['#default_value'] += (array) $settings['data'][$ent][$c][$table][$n][$name];
}
}
if ($table == 'address' && $name == 'master_id') {
$item['#attributes']['onchange'] = "web_civi_master_id({$c}, {$n});";
}
}
else {
$item = array(
'#type' => 'checkbox',
'#title' => $field['name'],
'#return_value' => 'create_civicrm_webform_element',
'#default_value' => !empty($settings[$fid]),
);
}
if ($d = webform_civicrm_aval($field, 'extra:description')) {
$item['#description'] = strlen($d) > 75 ? substr($d, 0, 75) . '...' : $d;
}
return $item;
}