Search code examples
drupaldrupal-7drupal-fapi

Extra text input in image widget -- Drupal 7


I have a content type that contains an image field and uses image_image widget. When editing the node I'd like to add an extra text input for each image. This text is not part of the node, I'd use it to generate a translation. I know how to do tweak other parts of the form, but here I'm lost between hook_form_alter() and hook_field_widget_form_alter(). How does one do this?

For now, I use hook_form_alter and an after_build function to twist the image's alt field into what I need to see in the node edit form. Then I move the submitted value to where I want it and copy the image's title field value into its alt field value. I don't mind them being the same. But I'm sad.


Solution

  • You can use Field collection to bundle your image field with an extra text field that goes with it.