Changing "add new node" button I have a content type "consultation" that has an inline entity reference to 1 node of a content type "prescription". This content type prescription has multiple inline entity references to the content type "medecine".

I'm using the module Inline Entity Form so I create/add all of these nodes in the creation form of "consultation".

I'm trying to change the text "Add new node" in the form to something else. I know how to do this when it's a direct entity reference, but how do I get to the "Add new medecine" for "medecine"?

This is my code so far:

function node_change_form_alter(&amp;$form, $form_state, $form_id) {
switch ($form_id) {
case 'consultation_node_form':
  $form['field_prescription_med']['und']['actions']['ief_add']['#value'] = t('Add new medecine');
  $form['field_prescription_med']['und']['form']['#title'] = t('Add new medecine');
  $form['field_prescription_med']['und']['form']['actions']['ief_add_save']['#value'] = t('Add new medecine');
  break;
}}


In this code:


field_prescription is the name of the entity reference field in "consultation" (to a "prescription")
field_prescription_med is the name of the entity reference field in "prescription" (to "medecine")
You can use hook_field_widget_WIDGET_TYPE_form_alter() to alter the button name

example: 


/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 */
function example_field_widget_inline_entity_form_form_alter(&$element, &$form_state, $context) {
  // Rename the button in specific form.
  if($form_state['build_info']['form_id'] == 'eck__entity__form_edit_sample_sample') {
    $element['actions']['ief_add']['#value'] = t('Add new medecine');
  }
}