[SOLVED][Drupal CCK] How to change the "Add another item" text?

| | 1 min read

A number of Drupal users using the Image field and the Filefield module related to the Drupal CCK module, wanted to know how to add the "Add another item " text to something of their choice. If you are facing the same situation with Drupal CCK in your Drupal site and would like to know how to change the "Add another item text" then read on to find out the solution.

Solution

  • You can use hook_form_alter to alter the node form and JS callback to change the #value property of the element of the field you wish to change
  • Use the sample code snippet below to change the Add another item text for mulitgroup and multi value fields
     t($field['widget']['label'])));
            }
            elseif (isset($elements[$key][$key .'_add_more']['#group_name'])) {
    
              // Obtain information about the multigroup.
              $groups = fieldgroup_groups($type_name);
              $group = $groups[$key];
    
              // Change the label of the button.
              $elements[$key][$key .'_add_more']['#value'] = t('Add another item to @name', array('@name' => t($group['label'])));
    
            }
    
          }
          else {
            // Recurse through all children elements.
            _mymodule_node_form_after_build_recursive($elements[$key]);
          }
        }
      }
    }
    ?>
  • Drupal 7 users can Download and install the custom Custom Add Another module to achieve the same effect

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We can provide a wide range of Drupal services to help you maintain and manage your Drupal websites. Get in touch with us to know more.