Either I'm completely missing something, or the code is broken. In attachment_nodeapi you switch on $op for 'settings' and 'form'. Neither of which ever get called. For example, when one goes to node/45/edit, it looks for attachment_form rather than attachment_nodeapi($node, 'form', ...).

The solution I made was to create a attachment_form($node) {} and attachment_setting() {} function.

According to hook_nodeapi() there is no $op of 'form' or 'settings'.

The reason I'm confused is: how could something this obvious slip into the code? Am I missing something?

Comments

peterjohnhartman’s picture

Correct that. To get it to work, I had to add attachment_form_alter() as follows:

function attachment_form_alter($form_id, &$form) {
  if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
      if (user_access('add attachments') && (variable_get("attachment_node_$node->type", 0) == 0)) {
        $node = node_load($form['nid']['#value']);
        $arg = 0;
        $form = array_merge($form, attachment_form($node, $arg));
        $form['#attributes'] = array('enctype' => 'multipart/form-data');
        $form['attachments']['#weight'] = 30;
     }

  }
}
ccourtne’s picture

Looks like you are using an old version. Please download the latest cvs version as it is fully working with 4.7 beta.

peterjohnhartman’s picture

Status: Active » Closed (fixed)

Story checks out. cvs upd for some reason didn't grab the latest. Now I have it and it works.

Thanks!