Implement hook_form_FORM_ID_alter(), rather than hook_form_alter()

phoehne - March 17, 2009 - 16:54
Project:Zeitgeist
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:minor
Assigned:fgm
Status:won't fix
Description

the function
zeitgeist_form_alter
should be renamed to
zeitgeist_form_search_form_alter
so its only called when this specific form is used.
with the actual version the hook is matches on every form on your site.

gruss peter

#1

fgm - March 18, 2009 - 13:30
Assigned to:Anonymous» fgm

Confirmed

#2

KiamLaLuno - June 21, 2009 - 10:31
Title:little performance issue» Implement hook_form_FORM_ID_alter(), rather than hook_form_alter()
Category:bug report» task

To rename zeitgeist_form_alter() is not enough, as zeitgeist_form_search_form_alter() would also require parameters that are different from the original function used.

Then, to use hook_form_alter() is not even a bug; it's simply code that has not been adapted to the new hooks made available from Drupal 6, but the old hook is still available, nor it has been reported as deprecated from the Drupal documentation.

#3

fgm - July 5, 2009 - 20:40
Status:active» needs review

I'm inclined to set "won't fix" because there is no obvious interest in having the two alters done in separate functions especially after today's changes.

Any other opinion (look at version 1.9.6.5 of zeitgeist.module) ?

#4

KiamLaLuno - July 6, 2009 - 15:29

It doesn't make any substantial differences, to keep the code as it is now.
I would say that to use one hook or the other is a question of coding preferences; maybe it would make a difference if the module would execute a long chain of IFs to differentiate the executed code basing on the form ID.

#5

fgm - July 6, 2009 - 07:01
Status:needs review» won't fix

OK, then.

 
 

Drupal is a registered trademark of Dries Buytaert.