I'm writing my own module called say "xmodule". I ran into a problem while implementing hook_view() which contains a submit action/button to itself (hook_view()). To wit, when I insert an submit button like this:

function xmodule_view(&$node, $teaser = FALSE, $page = FALSE) {
  ...
  $form .= form_submit(t('Toggle details'));
  ...
  $output .= form($form, 'post');
  $node->body = $output;
}

.. and then click on the button "Toggle details", the listing of all nodes is being shown (the effect is as if ?q=node is being executed). However, the url field in my browser still shows ?q=node/19, which matches the ACTION value in form tag.

Can anybody shed some light on this behaviour? Thanks.

Comments

nevets’s picture

The post back for the path node/19 is handled by the node module.
Since it does not understand 'Toggle details' as a valid operation, it displays the default node listing.
You could change the operation to view [form_submit(t('Toggle details'), 'view')] and then using a hidden field to keep track if details are being shown or not.