I have a views page with several exposed filters. I have created a link using a view php field as per below:
$url = '/admin/dashboard/applications/create/' . $row->nid . '?destination=' . current_path() . '&' . $_SERVER['QUERY_STRING'];
$link = '<a class="create-app" href="' . $url . '" title="Create application">App+</a>';
This leads to a form page with a confirmation 'Submit' or 'Cancel' button. The resulting URL on that page being something like this:
http://www.site.com/admin/dashboard/applications/create/154575?destination=admin/dashboard/enquiries&nid=&field_enquiry_fname_value=&field_enquiry_email_value=&field_enquiry_country_tid=&field_enquiry_campaign_id_value=&field_enquiry_emailed_value=0&field_enquiry_stage_1_tid=All&field_enquiry_enabled_value=1
When the redirect is done, the querystring after ?destination=admin/dashboard/enquiries is removed. I think this happens because it is not URL encoded.
I then tried url encoding the link as per below:
$query_string = array('destination' => current_path() . '&' . $_SERVER['QUERY_STRING']);
$url = url('admin/dashboard/applications/create/' . $row->nid, array('query' => $query_string));
$link = '<a class="create-app" href="' . $url . '" title="Create application">App+</a>';
This creates the following url:
http://www.site.com/admin/dashboard/applications/create/154575?destination=admin/dashboard/enquiries%26nid%3D%26field_enquiry_fname_value%3D%26field_enquiry_email_value%3D%26field_enquiry_country_tid%3D%26field_enquiry_campaign_id_value%3D%26field_enquiry_emailed_value%3D0%26field_enquiry_stage_1_tid%3DAll%26field_enquiry_enabled_value%3D1
The issue now is that when the redirect is done back to the views page, views does not recognize the URL query and does not load the view, and falls back to the parent menu callback.