tags:

views:

431

answers:

2

Hi there,

I have made a custom node type for event registration. I have used themes (template.php to all a custom tpl.php for the form) to customise the look of the form.

Using workflow and actions / triggers, people can register for my event, and the event manager gets a notification email and can log in and see a view of who has registered. Neat!

It all works wonderfully, but I can't find a way to rename the default drupal node/add buttons - "save" and "preview" to say "submit registration" and "preview registration". Just a small thing, but quite important to user experience.

Can anyone help me with this?

+3  A: 

You likely would want to use hook_form_alter() to alter the form and change the names of the submit buttons.

Unfortunately, you have to make a module to do this, because hook_form_alter() is not called on theme files.

mishac
A: 

Also, you can do without writing a module and just add a custom theme function, as detailed in this tutorial.

Basically you:

  1. Find the form id
  2. Create a mytheme_form_id theme function that alters the form returns drupal_render($form) (a little different from hook_form_alter)
  3. Find the correct form element. I just dpm($form) and look for the result. I think in your case it should be in a 'buttons' array, but don't take my word for it.
  4. Change the element.
  5. Implement a mytheme_theme hook in your template.php that registers the above-mentioned function
Eli Krupitsky
While doable, this type of change should probably remain consistent across themes. The difference in technical complexity between changing it in the theme and changing it in a small module is minor.
Grayside
Quote from the question: " I have used themes (template.php to all a custom tpl.php for the form) to customise the look of the form". That is - it's already highly customized. So, if anything, the opposite is true: it's better to put it all in the theme, rather than spread this single change out to a module.
Eli Krupitsky
That is, that change is an integral part of the theme, and therefore should stay within the theme. It's not about complexity (creating a hook_theme() is a little harder, if anything). Basically, it's for the reason you've mentioned: if the theme changes, that kind of thing (custom button labels) should change as well.
Eli Krupitsky
thanks, Eli. I think this fits the bill. I'll just have to find the right $form element.
Phil Dodd
For the record, the form element is$form['buttons']['submit']['#value']Thanks again
Phil Dodd