function _socialfield_field_instance_settings_form in Social field 7
Instance settings form process callback function.
1 string reference to '_socialfield_field_instance_settings_form'
File
- ./
socialfield.module, line 343 - Provides a field for adding social services links.
Code
function _socialfield_field_instance_settings_form($form, &$form_state) {
$form_state['#used_services'] = $form['#instance']['settings']['used_services'];
$form_state['#services'] = $form['#instance']['settings']['services'];
$form_state['#weights'] = $form['#instance']['settings']['weights'];
asort($form_state['#weights']);
$services = variable_get('socialfield_services');
$rows = array();
foreach ($form_state['#weights'] as $service_name => $weight) {
// Checking if service was deleted from module configuration.
if (!isset($services[$service_name])) {
unset($form_state['#services'][$service_name]);
unset($form_state['#weights'][$service_name]);
continue;
}
$use_service = in_array($service_name, $form_state['#used_services']);
$display_service = in_array($service_name, $form_state['#services']);
$service_markup = '<div class="social-links social-links-instance-settings">' . '<span class="service-' . $service_name . '">' . '<i class="icon ' . $services[$service_name]['icon'] . '"></i></span>' . '<span class="instance-settings-table-service-name">' . ucfirst($service_name) . '</span>' . '</div>';
$row = array(
'service_name' => array(
'#type' => 'hidden',
'#value' => $service_name,
),
'name' => array(
'#markup' => $service_markup,
),
'used_services' => array(
'#type' => 'checkbox',
'#default_value' => $use_service,
'#attributes' => array(
'class' => array(
'socialfield-table-used-service-checkbox',
),
),
),
'displayed_services' => array(
'#type' => 'checkbox',
'#default_value' => $display_service,
'#attributes' => array(
'class' => array(
'socialfield-table-displayed-service-checkbox',
),
),
),
'weight' => array(
'#type' => 'weight',
'#title' => t('Weight'),
'#title_display' => 'invisible',
'#default_value' => $weight,
'#attributes' => array(
'class' => array(
'services-order-weight',
),
),
),
);
if ($display_service) {
$row['used_services']['#attributes']['disabled'] = TRUE;
}
$rows[] = $row;
}
$module_path = drupal_get_path('module', 'socialfield');
// Theme this part of the form as a table.
$form['table'] = array(
'#theme' => 'socialfield_form_table',
'#header' => array(
t('Service'),
t('Used services'),
t('Displayed services'),
t('Weight'),
),
'rows' => $rows,
'#attributes' => array(
'id' => 'socialfield-instance-settings-services-table',
),
'#element_validate' => array(
'_socialfield_validate_services',
),
'#attached' => array(
'js' => array(
$module_path . '/js/socialfield.js',
),
'css' => array(
$module_path . '/css/socialfield.css',
),
),
);
return $form;
}