Hi. I have upgraded from views 2.11. to 6.x-3.x-dev to try out the new features.

When I run any views that implement hook_views_post_render(&$view, &$output), I get:

Fatal error: Call to a member function exposed_form_validate() on a non-object in ....\sites\all\modules\views\views.module on line 1073

I did the obvious things like:
- run update.php (there was nothing updated)
- check for any conversion under admin/build/views/tools/convert (nothing to convert)
- cleared cache
- I also tried to edit and save one of the views, so that it can save in view 3. But got the same error.

Please is there any upgrade that I need to do to the hooks, or is there an api change?

Unfortunately, I cannot the dump the views right now, as in production database.

I am using 6.x-3.x-dev of 2010-08-02.

Thanks for your help.

Comments

zeezhao’s picture

Fyi - I have some exposed fillters: date with from/to, node type, casetracker status.

The fields are mostly cck, or node fields,

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

When I run any views that implement hook_views_post_render(&$view, &$output), I get:

Can you pastebin the code you are using there? You might do something bad there.


Unfortunately, I cannot the dump the views right now, as in production database.

As you can read in http://drupal.org/node/571990 a export is important.
Please try to reproduce the bug on a clean drupal installation and describe how to reproduce the problem.

zeezhao’s picture

Thanks for your reply. I have just narrowed it down to some code in the hook which I am using the redisplay the filters into $output. Its the line calling drupal_build_form(). Works well in 2.11:

  		$view->init_handlers();
  		$form_state = array(
    			'view' => $view,
    			'display' => $view->display_handler->display,
    			'method' => 'get',
    			'rerender' => TRUE,
    			'no_redirect' => TRUE,
  			);

  		$output_filter = drupal_build_form('views_exposed_form', $form_state); //line causing bug

dawehner’s picture

Do you set the display?

Please paste all important code :)

dawehner’s picture

Status: Postponed (maintainer needs more info) » Fixed

      $this->view->init_handlers();
      return array(
        'content' => $this->view->render_exposed_form(TRUE),
      );

Is the code you should use here.

It's important that you have set the current display already

zeezhao’s picture

Status: Fixed » Active

Thanks for reply. Display is set to default.

Unfortunately cant post all code as need permission do to so first... Will try and get this or post a simulation, as it has dependencies on graphing etc.

But the general flow is the view produces results, however the results needs to be grouped and massaged in code. Hence use of hook_views_post_render(&$view, &$output).

- now the final output is done ok in views 3, but since its a dynamic report, the original filters need to be added in the output so the user can change anything and rerun if necessary.

- hence the need for the code above:
$output_filter = drupal_build_form('views_exposed_form', $form_state); //line causing bug

- and then for final output: $output = $output_filter . $output;

- so need to add the filters in front of output. Hence the use of drupal_build_form()

Tried the suggestion, but that wont work "Fatal error: Using $this when not in object context"

dawehner’s picture

This needs intelligent usage

      $this->view->init_handlers();
      return array(
        'content' => $this->view->render_exposed_form(TRUE),
      );

translates to

$view->init_handlers();
$view->render_exposed_form(TRUE);

I don't think this is a bug this is the changed api of views3 :)


Unfortunately cant post all code as need permission do to so first

That's bad luck :)

Letharion’s picture

Category: bug » support
Status: Active » Fixed

Seems to me dereine has answered the question, and it's been quite for a while, so I assume fixed. Please re-open otherwise.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

zeezhao’s picture

dereine's fix did not work. But was able to solve by adding extra line for exposed_form_plugin:

  			$view->init_handlers();
  			$form_state = array(
    			'view' => $view,
    			'display' => $view->display_handler->display,
			'exposed_form_plugin' => $view->display_handler->get_plugin('exposed_form'), //new extra line
			'method' => 'get',
    			'rerender' => TRUE,
    			'no_redirect' => TRUE,
  			);