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?

Comments

markus_petrux’s picture

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. ;-)

kenorb’s picture

Thank you.

I did that already in form_alter, but it's not good looking (I can't setup proper weight):

/**
 * 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;
    }
kenorb’s picture

http://drupal.org/node/144132#form-id-alter

Example modules that using it:
nodeaccess_userreference
nodeaccess_nodereference

kenorb’s picture

Status: Active » Fixed
kenorb’s picture