1

I have a view which is displayed from a theme method using views_get_view() and view::preview (see below). This view has an exposed filter. Unfortunately the exposed filter form does not work. When I submit the form it calls the wrong URL.

The wrong URL looks like this

http://domain?date_start=12

For comparison, the link of the sortable columns (which work as expected) does look like this:

http://domain/myselfcare/communications?order=destination&sort=asc&date_start=12

How can I fix this?

function theme_win_care_communications_page( $customer, $form, $form_state) {
  global $user;
  $output = '';
  watchdog('win_care', 'communications_page user=' . $user->uid . ', cust=' . $customer->id);
  $communications_view = views_get_view('drp_communications');
  $output .= $communications_view->preview('default', array($user->uid));

  // add an explanatory text
  if ($customer->reseller_id==33) { // mbudget only
    $output .= t('Note M-Budget: tariff is a function of the call time (in lots of 10 cents).');
  }
  else {
    $output .= t('Note: setup fee of 0.50 per call, minute rate according to current tariffs');
  }

  return $output;
}
1
  • what is the url it is calling? does it look "almost" right, eg, can you give more detail as to what it should look like versus what it is actually?
    – Jimajamma
    Commented Dec 4, 2011 at 1:12

1 Answer 1

1

Thanks for the additional info, it adds a lot of light to the issue. I am not exactly sure what is going on but maybe an explanation of what drupal does might give you an "A-ha! That's where I entered some info wrong" moment:

In the code, drupal/views/etc uses form redirects:

$form_state['redirect']= VARIABLE OR CODE TO SET IT TO A PATH

that is obviously mangling the redirect into:

http://domain/?date_start=12

What is interesting here is it is setting that url to the date_start value instead of adding that to the url:

http://domain/myselfcare/communications?order=destination&sort=asc&date_start=12

So here, instead of adding ?date_start=12 to the end of

http://domain/myselfcare/communications?order=destination&sort=asc

it's replacing it all (additional vars get the ?= changed to an &=)

So, I'd look at how you are defining date_start in your view forms and see if anything odd pops up there. That or in your theme code setting the redirect to that directly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.