I am building an exposed filter dynamically. When the value is changed the ajax form callback is called to rebuild the form, but it gives error.
The form field to which the ajax callback is attached is a select field.. The error is
Call to a member function exposed_form_validate() on a non-object .
I have looked into the error and found that the
$exposed_form_plugin->exposed_form_validate($form, $form_state);
code is called on an object and $exposed_form_plugin is not being passed as an object. The variable gets its value from $form_state['exposed_form_plugin']. So i have induced that $form_state is definitely not an object. What am i doing wrong that the form_state is not being passed as object?
$form_state
isn't supposed to be an object; it's the FAPI$form_state
and will always be an array (see the code inviews_plugin_exposed_filter::exposed_form_validate()
as an example). Do you mean why is$form_state['exposed_form_plugin']
not an object? If so could you expand the question a bit to explain why you're expecting it to be an object, and add some more of you code in?$form_state
will always be an array, never an object. Check the link I provided in the last comment for an example straight from the views module itself. As you'll see,$form_state
is accessed as an array, not an object. If you want to prove it just add anis_array($form_state)
check in there somewhere. I guarantee it'll returnTRUE