0

How can I modify the field names of the location widget that I use to collect addresses and phone numbers. I am using Drupal 7 with the Location Module: https://drupal.org/project/location

Below a screenshot of the fields I would like to rename ('Street Location' to 'Address Line 1' as an example). enter image description here

Thanks!

2
  • You need to update your question to actually specify what modules you're using. As of now, it's anyone's guess. All I know is this isn't Address Field, so I've removed that tag. Dec 5, 2013 at 15:12
  • @RyanSzrama Thank you for pointing this out. I am using the Location module drupal.org/project/location. I updated the description and the title. Thanks again. Dec 5, 2013 at 15:40

3 Answers 3

2

https://www.drupal.org/node/381458#comment-6699162 worked for me

/**
 * Implements hook_location_element_alter().
 */
function update_personal_info_location_element_alter(&$element) {
  $element['additional']['#title'] = "Address line 2";
}
0

The location is essentially a custom table location in the database with all those columns (ew). Having looked through the code they make Drupal form elements for each column in the table as needed.

I suggest hook_form_alter to simply change the title disabled where needed when displaying the location on page forms.

there are a zillion examples here on stackexchange of how to use hook_form_alter.

0

Here's the suggestion.

There are various options to do so.

  1. Use "String Overrides" module

  2. Make a module that implements hook_form_alter() to change the help text.

  3. In location.module, change: '#title' => t('Street Location'), to '#title' => t('Address Line 1'),

Though 3rd one is not best practices since it makes updating the module harder.

Let me know if you face any query/concern regarding this.

Thanks!

1
  • hook_form_alter is not working.b/c field title is not avalable their
    – Lucifer
    Aug 6, 2015 at 15:04

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.