function signaturefield_field_settings in SignatureField 6
Implementation of hook_field_settings().
File
- modules/
content.inc, line 33 - Content module integration.
Code
function signaturefield_field_settings($op, $field) {
switch ($op) {
// Create the form element to be used on the field
// settings form. Field settings will be the same for
// all shared instances of the same field and should
// define the way the value will be stored
// in the database.
case 'form':
$form = array();
$form['color'] = array(
'#type' => 'textfield',
'#maxlength' => 7,
'#size' => 7,
'#title' => t('Color'),
'#default_value' => isset($field['color']) ? $field['color'] : NULL,
'#required' => FALSE,
'#description' => t('Hex code for pen color (default is black)'),
);
$form['width'] = array(
'#type' => 'textfield',
'#maxlength' => 3,
'#size' => 3,
'#title' => t('Width'),
'#default_value' => isset($field['width']) ? $field['width'] : NULL,
'#required' => FALSE,
'#description' => t('Custom width in pixels'),
);
$form['height'] = array(
'#type' => 'textfield',
'#maxlength' => 2,
'#size' => 2,
'#title' => t('Height'),
'#default_value' => isset($field['height']) ? $field['height'] : NULL,
'#required' => FALSE,
'#description' => t('Custom height in pixels'),
);
return $form;
// Return an array of the names of the field settings
// defined by this module. These are the items that
// CCK will store in the field definition
// and they will be available in the $field array.
// This should match the items defined in 'form' above.
case 'save':
return array(
'color',
'width',
'height',
);
// Define the database storage for this field using
// the same construct used by schema API. Most fields
// have only one column, but there can be any number
// of different columns. After the schema API values,
// add two optional values to each column,
// 'views', to define a Views field
// 'sortable', to add a Views sort field
case 'database columns':
$columns['value'] = array(
'type' => 'text',
'size' => 'normal',
'not null' => FALSE,
'sortable' => TRUE,
'views' => TRUE,
);
return $columns;
// Optional: Make changes to the default $data array
// created for Views. Omit this if no changes are
// needed, use it to add a custom handler or make
// other changes.
case 'views data':
// Start with the $data created by CCK
// and alter it as needed. The following
// code illustrates how you would retrieve
// the necessary data.
$data = content_views_field_views_data($field);
$db_info = content_database_info($field);
$table_alias = content_views_tablename($field);
$field_data = $data[$table_alias][$field['field_name'] . '_value'];
// Make changes to $data as needed here.
return $data;
}
}