All i want to do is change the name of the titles in the location form,
I want to change the name of street and city.... but cannot seem to be able to work out how to do this...

Can you guys please give me a pointer

cheers
please can you reply asap we have a presentation on tuesday :|
this is the only thing that is holding us back ....

Comments

tom_o_t’s picture

Priority: Critical » Normal

You'll probably need to create a custom module and use hook_form_alter() to change the titles.

API documentation is at http://api.drupal.org/api/function/hook_form_alter/5 but is not that useful.

See also http://www.drupaldojo.com/minilesson/hook-form-alter-breakdown and http://www.hiveminds.co.uk/node/3109 for more useful tutorials

o0_Enigma_0o’s picture

Hi

thanks for the reply

is there no other way? that hook_form stuff looks a bit over my head :|

cant i just edit the module files?

o0_Enigma_0o’s picture

Just been thinking...
where do these forms get there information from?
i have checked every file within the mod to see whats going on...

none even have referance to the field names... :|

but i am thinking, are the names stored in the database and if so could i just change the names within the database?

tom_o_t’s picture

It's a really bad idea to change the modules as it means you can't update the modules when new releases come out.

The form titles probably come from the location module. I don't think the titles are in the database, though looking at the code in the location module should make that clear.

I'd really recommend just persevering and learning how to use hook_form_alter. Once you understand that you'll be a much better Drupal developer! It will pay off in the long-term...

If you are using the location module you could check out the issue queue in that module, and you may find someone who's dealt with the same issue.

o0_Enigma_0o’s picture

hi guys...
right i have had ago at this form alter thing and nothing is working..

if i post my code into here could you guys give me some pointers ... pls....

the form object i want to change lands in this code

<div class="form-item"><label for="edit-locations-0-street" >Street: </label></div></td><td align="left"><div class="form-item">

 <input type="text" maxlength="64" name="locations[0][street]" id="edit-locations-0-street"  size="64" value="" class="form-text" />
</div>

All i want to change is the word "street" to "building number and street"

my form information

<form action="/addevent"  method="post" id="node-form" enctype="multipart/form-data">

(that is the highest form tag for this form so i think this is the right one)

Ok.

I have been looking at the hook_form_alter stuff and couldnt get my head round it so i went insearch of more info.. and found this http://www.lullabot.com/articles/modifying-forms-5-and-6
i have been following some info on this and tried to put the code in template.php like it says... again nothing seems to happen, but the problem is i am not a php programmer... infact im not really a programmer,
if any of you guys can help it would be fantastic

Many thanks

tom_o_t’s picture

Create a new module called location_tweak.module with the necessary .info file to go with it.

In this module:

function location_tweak_form_alter($form_id, &$form){
        // print $form_id . ' '; // this prints form_id's of all forms on every page - development feature

        // When an event is being added change the title of the street address field
        if($form_id == 'event_node_form') {

                $form[locations][0][street]['#title'] = 'building number and street';
         }
}

I'm just guessing about $form_id == 'event_node_form'
To get the correct form id you can un-comment the line beginning print $form_id - this will print all form ids on the page and you can figure out which is the correct one.

Remember that your module should not have the closing ?> tag, but will need the opening one.

Good luck! Remember to follow all the usual guidance for where to put your module - I'm sure you can find that in the handbook if you don't already know.

o0_Enigma_0o’s picture

hi tom_o_t,

I am gonna try your code out vsoon, just need to read up on the .info file...

Thanks for your help i will let you know how i get one

o0_Enigma_0o’s picture

thats flipping fantastic ;)
thanks so much for your help

Just made the module and uploaded... i used your first bit of code to find the name of the form first... turned out to be eventgig_node_form, i am going to have to read up on changing more bits now... my location form still needs work..

Thanks again

rooby’s picture

Status: Active » Closed (won't fix)

Drupal 5 is no longer supported.

If this issue affects drupal 6 or 7 please look for an existing issue for that version or else update this issue accordingly.