[development] Giving form_alter an $op and calling it more
than once.
Darrel O'Pry
dopry at thing.net
Tue Apr 18 15:04:58 UTC 2006
On Tue, 2006-04-18 at 07:41 -0700, Earl Miles wrote:
> Robert Douglass wrote:
> >
> > hook_form_additions
> > hook_form_alter
>
> Alternatively, you can do what I've done and add an '#after_build' to
> which will do almost exactly what you want.
>
> <?php
>
> my_hook_form_alter(...) {
> $form['my_addition'] = array(...stuff...);
> $form['my_addition']['#after_build'] = 'my_function_call'; // or maybe
> the key => args notation once after_build is modified to be an array of
> calls like everything else.
> }
>
> The downside of course is that you can only have one #after_build...per
> form element. But each form element can have one.
>
The upside... the way FormAPI is built we don't have to iterate through
all the modules looking for 'my_function_call'. unrolling some inner
loops would probably be good for drupal, expecially in our callback
systems.
Even then Drupal's hooks, whether anyone has stated it or not, are
events. A lot of event driven systems do make their modules register
callbacks to events. I'm sure some of the more mature event systems have
developed ways to cope with ordering issues. FormAPI is a really nice
since in a way it provides callback registration.
btw, I'm in the form_alter phases camp.. form_alter($op,$node, $form) or
similar.
More information about the development
mailing list