[development] Important nodeapi change
Vernon Mauery
vernon-drupal at mauery.com
Fri Dec 9 18:58:23 UTC 2005
Karoly Negyesi wrote:
> Hi!
>
> Sorry for not announcing this change on Monday.
>
> nodeapi op 'form' is no more. Use hook_form_alter instead. This lets you not
> just add to the node form but change at will.
>
> See the core modules for examples. The conversation process is the following:
> let's suppose we have foo.module , and it compiles its nodeapi form in
> _foo_form which takes one argument, $node. and the last command is return
> $form (core actually had such functions). Then we can rename _foo_form to
> foo_form_alter and wrap the code as follows:
>
> function foo_form_alter($form_id, &$form) { if (isset($form['type']) &&
> $form['type']['#value'] .'_node_form' == $form_id) { $node = $form['#node'];
> // _form_form code follows: $form['foo']['myfield'] = array(...); // the
> final return is not needed because $form is a reference. } }
I have a problem with this change. In the Acidfree module, there is a view
called 'Ablum Contents' that allows you to do mass edits of the items in the
album. You know, changing titles, descriptions, taxonomy, node_access, etc.
This is done with a tree form where each node in the album has a branch of the
tree with all its values. Like edit[nodes][0..n][all the per-node values]
The form is not called acidfree_node_form though. This makes it so that the
taxonomy form does not want to put its form item into the node branches of my form.
The old nodeapi way allowed me to do this easily. Are there any suggestions of
how to do this with the form_alter method? Should I pass a branch of my form in
and invoke the hook_form_alter hook?
--Vernon
> I added this to the handbook, too.
>
> Regards
>
> NK
>
>
More information about the development
mailing list