Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By skolaric on
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
Path node/19 handled by node module
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.