Drupal 7: How to alter image field widget "alt" or title" label -
i trying change "alt" , title" labels in image widget on node add form.
i have tried both of these hooks:
hook_field_widget_form_alter hook_form_alter
i unable find needed go alter label. 1 please direct me appropriate way hook , alter them? i'm hitting these custom module if makes difference. hitting them via theme fine me well.
any ideas anyone?
you have add extra proccess function widget form.
you can use dpm($element) devel module find more details available keys, options etc.
// alter image title field_top_image instance function mymodule_field_widget_form_alter(&$element, &$form_state, $context) { // if image field type of instance 'field_image_top' if ($context['field']['field_name'] == 'field_image_top') { // loop through element children (there @ least one). foreach (element_children($element) $key => $child) { // add new process function element //dpm($element); $element[$key]['#process'][] = 'mymodule_image_field_widget_process'; } } } function mymodule_image_field_widget_process($element, &$form_state, $form) { // change title field label , description //dpm($element); $element['title']['#title'] = 'new title'; $element['title']['#description'] = 'some new description here.'; // return altered element return $element; }
see similar issue: https://drupal.stackexchange.com/questions/32861/how-do-i-alter-image-field-code-without-hacking-core
Comments
Post a Comment