function geofield_field_settings_form in Geofield 7.2
Implements hook_field_settings_form().
File
- ./
geofield.module, line 93
Code
function geofield_field_settings_form($field, $instance, $has_data) {
ctools_include('plugins');
$settings = $field['settings'];
$backend_options = array();
$backends = ctools_get_plugins('geofield', 'geofield_backend');
foreach ($backends as $id => $backend) {
if (isset($backend['requirements'])) {
if ($backend['requirements']) {
$callback = $backend['requirements'];
$error = '';
if (!$callback($error)) {
$form['backend_error'][] = array(
//@@TODO: Use t() func
//@@TODO: css to add some red and bold
'#markup' => '<div class="geofield-backend-error">' . $backend['title'] . ' not usable because ' . $error . '</div>',
);
continue;
}
}
}
$backend_options[$id] = $backend['title'];
}
$form['backend'] = array(
'#type' => 'select',
'#title' => 'Storage Backend',
'#default_value' => $settings['backend'],
'#options' => $backend_options,
'#description' => "Select the Geospatial storage backend you would like to use to store geofield geometry data. If you don't know what this means, select 'Default'.",
'#disabled' => $has_data,
);
$form['settings'] = array(
'#tree' => TRUE,
);
// Expose backend-settings, if they have them
foreach ($backends as $id => $backend) {
if (isset($backend['settings'])) {
if ($backend['settings']) {
$callback = $backend['settings'];
$form[$id] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#title' => $backend['title'] . ' Settings',
'#states' => array(
'visible' => array(
':input[name="field[settings][backend]"]' => array(
'value' => $id,
),
),
),
);
$form[$id] = array_merge($form[$id], $callback($field, $instance, $has_data));
}
}
}
return $form;
}