1

I want to call my custom field_widget_form with the use of drupal_get_form() Is it possible to do that? simple requirement .. I want to build a form where user enter the field value and that value should be store with the node but only one field value instead of all 30 fields.

Now i have created the field with custom code so how can i call this function field_widget_form() in that or any other help full alternative.

  • is there any chance you can update/re-phrase the question a bit. I believe I have the same the question, but can't tell, and the answer doesn't make sense to me? – Letharion Mar 14 '12 at 14:14
3

When you define a widget form, you can change it from another module with hook_field_widget_form_alter(), which requires Drupal 7.8 or higher.

function hook_field_widget_form_alter(&$element, &$form_state, $context) {
  // Add a css class to widget form elements for all fields of type mytype.
  if ($context['field']['type'] == 'mytype') {
    // Be sure not to overwrite existing attributes.
    $element['#attributes']['class'][] = 'myclass';
  }
}

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.