I am using form Api to create a custom form. My form is below.
function myform_form() {
$form = array();
$form['name'] = array(
'#type' => 'textfield',
'#title' => t(''),
'#required' => FALSE,
'#weight' => 2,
);
$form['telephone'] = array(
'#type' => 'textfield',
'#title' => t(''),
'#weight' => 3,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('submit'),
);
return $form;
}
function myform_submit($form, &$form_state) {
drupal_set_message(t('Your form has been submitted successfully.'));
$form_state['redirect'] = 'thankyou';
}
I used to show this form in lightbox as this :
<a href="/myform" rel="lightframe"> Form </a>
Form is correctly showing in lighbox. But when i submit the form it opens the thankyou
page in popup.
I used
<a href="/myform" rel="lightmodal"> Form </a>
It closes the popup event if form validation returns false. I don't want to close the popup if there is any validation error. I added this to myform_submit
function :
parent.Lightbox.end();
But drupal_add_js
is not working in myform_submit
function.
Updated :
I send a parameter to thank you page and added this on the page load.
<?php if($_GET['redirect']) { ?>
<script>
window.parent.location = "quick_request_quote";
</script>
<?php } ?>
Its redirecting but it shows content in popup for few seconds and redirect after that. I don't want to display popup for a second also after submitting the form.