0

What is the best way to modify the File field so the "Description" field is a select box instead of a text field. I.e. I want to go from:

enter image description here

To this:

enter image description here

I tried a quick experiment, editing the File modules file.field.inc file, which resulted in the screenshots above, but if I can avoid forking the File module and instead do it some other way it would be great.

2 Answers 2

1

You can use hook_field_widget_form_alter() to add your own #process callback to the element.

In the callback you can just change the description field from a textfield to a select.

1
  • Awesome, thought there should be a better way. Can you help out with a code example? Nov 2, 2012 at 10:07
1

Turns out the easiest solution is to use the Field Collection module, which allows me to do just what I want.

2
  • Just as an FYI, there's also the File entity module, which extends files to become fieldable entities in their own right.
    – Chapabu
    Nov 2, 2012 at 14:15
  • @Chapabu, thank, I will have to look into that as well. Nov 2, 2012 at 16:15

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.