I've been trying for a while now to alter the Description form field that appears after a file has been uploaded. Basically I just want to give the field a different #title and add a #description, but I can't seem to get it. The form alter function works otherwise for other form elements, so maybe it's just my targeting. Used dpm() to try and sort it out, but no luck.

Here's what I have now:

$form['field_document_file']['0']['data']['description']['#title'] = t('Document Title');
$form['field_document_file']['0']['data']['description']['#description'] = t('Enter a document title.');

Any help would be greatly appreciated, I need to do this for a couple of upcoming projects as well.

Thanks

Comments

quicksketch’s picture

Status: Active » Fixed

You can't get at these field through hook_form_alter() directly because they are added in #process functions (after hook_form_alter() runs). In order to modify these "sub fields" you need to add your own #process function to the field, then modify the field in that process callback. I suggest looking at modules like ImageField Extended for an example of how to do this. I do not provide coding support in the issue queue, so you'll have to take it from there.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.