Adding custom settings to the field
kenorb - May 22, 2009 - 14:09
| Project: | Content Construction Kit (CCK) |
| Version: | 6.x-2.x-dev |
| Component: | Documentation |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
Description
I would like to add some custom settings to each field.
Similar to max_length.
How it's possible?
I've seen max_length is defined in text_field_settings()
So I've tried hook_field_settings, but it's even not executed on admin/content/node-type/%/fields/field_%
So should I make it in form_alter way?

#1
I think you need this: #417122: Allow drupal_alter() on Field and Widget Settings
Bump that one if it covers your needs, so maybe that helps to catch CCK maintainer's attention. ;-)
#2
Thank you.
I did that already in form_alter, but it's not good looking (I can't setup proper weight):
<?php/**
* Implementation of hook_form_alter().
*/
function foo_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'content_field_edit_form':
$field_name = $form['#field']['field_name'];
$form['foo']['foo_name'] = array(
'#type' => 'textfield',
'#title' => t('My custom settings of field'),
'#default_value' => CHANGE_THAT,
'#weight' => -10,
);
$form['#submit'][] = 'foo_field_submit'; // submit, where we can store this settings
break;
}
?>
#3
http://drupal.org/node/144132#form-id-alter
Example modules that using it:
nodeaccess_userreference
nodeaccess_nodereference
#4
#5
#417122: Allow drupal_alter() on Field and Widget Settings