function viewfield_field_settings in Viewfield 6
Same name and namespace in other branches
- 5 viewfield.module \viewfield_field_settings()
- 6.2 viewfield.module \viewfield_field_settings()
Implementation of hook_field_settings().
File
- ./
viewfield.module, line 29 - Core functions.
Code
function viewfield_field_settings($op, $field) {
switch ($op) {
case 'form':
$form['allowed_views'] = array(
'#type' => 'checkboxes',
'#title' => t('Allowed values'),
'#default_value' => is_array($field['allowed_views']) ? $field['allowed_views'] : array(),
'#options' => drupal_map_assoc(array_keys(views_get_all_views())),
'#description' => t('Only selected views will be available for content authors. Leave empty to allow all.'),
);
$form['super_default'] = array(
'#type' => 'checkbox',
'#title' => t('Use a common default value for all nodes if the user does not override it on the node form.'),
'#default_value' => $field['super_default'],
);
$form['token_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Replace token placeholders'),
'#description' => t('Negatively affects site performance in combination with %fields row style.', array(
'%fields' => t('Fields'),
)),
'#default_value' => $field['token_enabled'],
'#access' => module_exists('token'),
);
$form_state = NULL;
$form['#node'] = (object) array(
'type' => $field['type_name'],
);
module_load_include('inc', 'content', 'includes/content.node_form');
$field_form = content_field_form($form, $form_state, $field, 0);
$form['super_default_widget'] =& $field_form[$field['field_name']][0];
$form['super_default_widget']['#tree'] = TRUE;
unset($form['super_default_widget']['#weight']);
return $form;
case 'validate':
if ($field['force_default'] && $field['multiple']) {
form_set_error('multiple', t('Multiple views are not supported if force default is enabled.'));
}
break;
case 'save':
return array(
'allowed_views',
'super_default',
'token_enabled',
'super_default_widget',
);
case 'database columns':
return array(
// Views requires at least 96 chars for the view name and display, plus
// we need 1 for our delimiter. Round up to a common value of 128.
'vname' => array(
'type' => 'varchar',
'not null' => FALSE,
'length' => 128,
),
'vargs' => array(
'type' => 'varchar',
'not null' => FALSE,
'length' => 255,
),
);
}
}