RSS

Category Archives: drupal

common errors and tips while coding in drupal

|| drupal 7 || tutorial || popup with html form

In drupal 7, once i have to show a comment form in the popup. I used the greybox jQuery plugin to show a drupal comment form in popup and find that the whole page along with the interface get called in the popup whereas i just need to show the form only. I was suggested to call a html page having only the html form to be displayed in the popup window. As far as interface is concerned, its ok with the comment form in the popup but how to manage the html form action in drupal. i have to specify some redirection url in html form action=”” but what exactly?

hook_menu is there to introduce new urls as

function mymodule_menu() { //{moduleName}_menu

$items['custom_page'] = array( 
// {baseurl}/custom_page will be the url

'page callback' =>'html_form_action',
//function to be called by {baseurl}/custom_page

'access callback' => TRUE,

'type' => MENU_NORMAL_ITEM,

);

return $items;

}

function html_form_action() {

global $base_url;

//form action handling here

drupal_goto($base_url."/sites/all/modules/mymodule
/comment.php",array('query'=>array('status'=>$status))); 
// redirection to html form page to handle the 
//appropriate form action response

}

and in html

 <form action="{baseurl}/custom_page" …>

That’s it 🙂

Note: If you find that under the Navigation block there is a bullet without any title, then this is due to the menu we have created. For hiding that unnecessary bullet goto {base_url}/admin/structure/menu/manage/navigation and disable the unwanted bullet.

Advertisements
 
3 Comments

Posted by on October 20, 2011 in drupal

 

Tags: , , , , , , ,

 
%d bloggers like this: