Currently I am using a https://drupal.org/project/ctools_automodal for my modal forms, that use CTools and its form dialogs for nice overlay forms (well not so nice, they look ugly as hell, but you can theme things :) ).
So there are some good tutorials how to setup modal forms and make you forms in overlay
http://deeson-online.co.uk/labs/insert-form-pop-modal-ctools-and-drupal…
http://drupion.com/blog/10-steps-creating-ctools-modal-window-drupal-7
But screw those. You can use automodal module I mentioned above and save yourself lot of leg work to setup a modal form. What you really do in the end is just use 'modal' => TRUE, in your menu hook and it works out of the box. Anyway to get back to the point. You will probably want to close that dialog modal form when submited and this automodal module doesn't do that by default. So you need to add some code to your form.
function custom_form($form, &$form_state)
{
$form = array();
$form['something'] = array(
'#type' => 'textfield',
'#title' => t('Enter'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
if ( $form_state['submitted']){
$commands[] = ctools_modal_command_dismiss();
$commands[] = ctools_ajax_command_redirect('');
print ajax_render($commands);
exit;
}
return $form;
}
function custom_form_submit(&$form, &$form_state) {
$form_state['rebuild'] = TRUE;
}
So what we do is rebuild a form on submit, then check if form is submitted and use commands[] array to add two functions and render it. We first use
ctools_modal_command_dismiss() to close the modal dialog and then use
ctools_ajax_command_redirect('
Then we render it and exit the form.
For the rest of ctools and ajax functions, check the list here.
http://drupalcontrib.org/api/drupal/drupal%21includes%21ajax.inc/7
http://drupalcontrib.org/api/drupal/contributions%21ctools%21includes%2…
You can also dismiss ctools_modal_command_dismiss if you want as redirect will just redirect to the proper place and close modal dialog.