I need to have a select widget but with custom allowed values per user. Since in D7 I cannot use php code, I was wondering if there is some kind of hook I could use to achieve that functionality.



This would be hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0).

The example code for the hook, reported in the documentation is the following one.

function hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $element += array(
    '#type' => $instance['widget']['type'], 
    '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
  return $element;
  • thanks. I think hook_field_widget_form_alter() is more what I'm looking for. I'll try it sometimes this week Mar 14 '12 at 14:14
  • true .. just copied it from a module ;)
    – rémy
    Mar 14 '12 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.