2

I wanted to change the title of a node field on the node display page.

I have implemented hook_node_view() and changed the title in code using following code:

$node->content['my_field']['#title'] = t('Field Name');

When I dpm() the $node object I can see that above code has been successfully executed, but on node display page I still don't see the field name changed.

I also did a dpm() of $content from tpl file and found out that $content['my_field']['#title'] has been set to 'Field Name' as per above code. But it still displays the older title.

Whay may be causing this to happen?

3
  • What is the fields type?
    – Felix Eve
    Apr 28, 2014 at 11:20
  • @FelixEve: It is a select list field
    – kmdhrm
    Apr 28, 2014 at 11:28
  • 1
    Could you please post the completed hook implementation code blcok? Apr 28, 2014 at 11:39

1 Answer 1

0

Hi you have added extra fields in the content variable so you have to override the old title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.