Hello,

I have a particularly complex view set, I am not convinced that the combination of modules is causing the issue I am reporting. However, I will do my best to explain the whole design pattern as it may provide insight into other issues.

Error Identified:

Notice: Undefined property: views_handler_field_field::$original_value in views_handler_field->render_text() (line 1118 of /srv/clients/example/code/sites/all/modules/contrib/views/handlers/views_handler_field.inc). Backtrace:

views_handler_field->render_text(Array) views_handler_field.inc:1065
views_handler_field->advanced_render(Object) theme.inc:354
template_preprocess_views_view_field(Array, 'views_view_field') theme.inc:1008
theme(Array, Array) views_handler_field.inc:1440
views_handler_field->theme(Object) views_plugin_style.inc:526
views_plugin_style->render_fields(Array) views_plugin_style.inc:431
views_plugin_style->render_grouping(Array, Array) openlayers_views_style_data.inc:25
openlayers_views_style_data->render(Array) openlayers_views_plugin_display_openlayers.inc:26
openlayers_views_plugin_display_openlayers->render() view.inc:1232
view->render() openlayers_views_plugin_display_openlayers.inc:18
openlayers_views_plugin_display_openlayers->execute() view.inc:1313
view->execute_display('members_map_openlayers_data', Array) openlayers_views_vector.inc:63
openlayers_layer_type_openlayers_views_vector->get_features('member_index_map', 'members_map_openlayers_data') openlayers_views_vector.inc:80
openlayers_layer_type_openlayers_views_vector->render(Array) openlayers.render.inc:39
_openlayers_layers_process(Array, Array) openlayers.module:168
openlayers_build_map(Array) openlayers.module:201
openlayers_render_map_data(Array, 'member_index_map') openlayers.module:264
openlayers_render_map(Object, 'member_index_map') openlayers_views_style_map.inc:66
openlayers_views_style_map->render(Array) theme.inc:49
template_preprocess_views_view(Array, 'views_view') theme.inc:1008
theme(Array, Array) views_plugin_display.inc:2561
views_plugin_display->render() view.inc:1232
view->render() views_plugin_display_page.inc:229
views_plugin_display_page->execute() view.inc:1313
view->execute_display('members_map_openlayers_map', Array) views.module:475
views_page('member_index_map', 'members_map_openlayers_map') 
call_user_func_array('views_page', Array) menu.inc:517
menu_execute_active_handler() index.php:21

0) Entity
I have an entity called "member" that has a "sub-entity" curtesy of the field collection module (http://drupal.org/project/field_collection) that contains a 3 field entity attached to the "member" parent. Because of the embedded entity I have had to add a relationship between the parent and child entities. I have accomplished the integration correctly and the data is displayed both in lists of members and in filters based on the relationship.

1) Openlayers
I have setup an open layers map and the view in question has a "OpenLayers Data Overlay". This view format appears to be working as designed. The fields and filters all work fine and provide the JSON structure required for the Open Layers map to render.

2) Page View
The page view provides a rendering display for the Open Layers data overlay it contains exactly the same fields and filters as the Openlayers Data Overlay view. The filters are exposed and I can successfully filter records by multiple criteria from text fields, taxonomy and node reference relationships.

3) Attachment View
This is where things go a little off the rails.

The attachment contains all of the same fields and filters as the parent views both "Openlayers Data" and the "page view". It's job is to list all of the member records that are being used in the Map rendered on the "page view". As the user selects filters the list should reflect the sub-select that is displayed on the map.

On or more filters appear to be unhappy, the first is a taxonomy reference field that displays none or more terms. The field is of type autocomplete and can be empty. The error being generated in the attachment leads me to believe that the handler for this field is not validating correctly and not excluding it from the query (please reference the error above).

I have found it difficult to try and configure the filter to reproduce the error during configuration or from within the view preview. Viewing the attachment view directly in the Views UI it will render as expected without any errors. The attachment will not render in the "map page view" although the view does show the wrapper where the attachment should be rendered.

My next course of action is to attempt to try the following:

1) Modify the default view handler and trace where the error occurs, is it in Openlayers view or is it in the core code of Views?

2) Write a hook to intercept the specific field on the attachment view and clobber it should it be empty.

Please provide any recommendations or patches that may already exist related to this issue.

Comments

emptyvoid’s picture

Follow up, under closer inspection of the query generated for the attachment view I have confirmed that the "product_services" filter field is the problem.

Current Query:

SELECT DISTINCT 
	node.nid AS nid, 
	node.title AS node_title, 
	node.language AS node_language, 
	field_data_field_member_address.field_member_address_thoroughfare AS field_data_field_member_address_field_member_address_thoroug, 
	field_data_field_member_address.field_member_address_locality AS field_data_field_member_address_field_member_address_localit, 
	field_data_field_member_address.field_member_address_administrative_area AS field_data_field_member_address_field_member_address_adminis, 
	field_data_field_member_address.field_member_address_postal_code AS field_data_field_member_address_field_member_address_postal_, 
	'node' AS field_data_field_main_contact_node_entity_type
FROM 
	node node
LEFT JOIN field_data_field_member_cert_programs field_data_field_member_cert_programs 
	ON node.nid = field_data_field_member_cert_programs.entity_id
	AND (field_data_field_member_cert_programs.entity_type = 'node' AND field_data_field_member_cert_programs.deleted = '0')
LEFT JOIN field_collection_item field_collection_item_field_data_field_member_cert_programs 
	ON field_data_field_member_cert_programs.field_member_cert_programs_value = field_collection_item_field_data_field_member_cert_programs.item_id
LEFT JOIN field_data_field_member_products_services field_data_field_member_products_services_value_0 
	ON node.nid = field_data_field_member_products_services_value_0.entity_id 
	AND field_data_field_member_products_services_value_0.field_member_products_services_tid = ''
LEFT JOIN field_data_field_member_address field_data_field_member_address 
	ON node.nid = field_data_field_member_address.entity_id 
	AND (field_data_field_member_address.entity_type = 'node' 
	AND field_data_field_member_address.deleted = '0')
WHERE 
	(
		( 
			 (node.status = '1') 
		 AND (
			node.type IN  ('base_member')) 
			AND( (field_data_field_member_products_services_value_0.field_member_products_services_tid = '') 
			)
		)
)
ORDER BY node_title ASC

The desired behavior is to exclude the field_data_field_member_product_services field from the inner join and where clauses of the query if it is empty. It is especially troubling is that the "where" clause also uses "=" when the field is a one to many relationship. If anything I would expect it to look like:

WHERE
 (
    (
       (node.status = '1')
       AND (node.type IN ('base_member'))
       AND ( (field_data_field_member_products_services_value_0.field_member_products_services_tid IN ('568,467,12,567')))
       )
    )
 )

If the filter had values.

I am going to try and track down the hooks required to modify the pre_render and or a hook explicitly for the filter.

emptyvoid’s picture

For future reference the following page provides a description on how to target a specific filter and modify it.

http://views-help.doc.logrus.com/help/views/alter-exposed-filter

johnv’s picture

Status: Active » Closed (duplicate)
emptyvoid’s picture

Status: Closed (duplicate) » Active

Thanks jonv for the pointing me to the issue. I have applied the patch but it didn't fix the issue I am having.

I'll post if the solution required either a) reconfiguring the field or b) writing a special hook to override the behavior.

johnv’s picture

sebsebseb123’s picture

Hey hey, in case anyone else is having the issue of no results showing up... I found a work around.

My setup is:
- D7
- Views 3
- openlayers 2-beta
- openlayers_proximity 2-dev

My view is as described above... map, with attachment.

I tried some patches that were mentioned in this thread... none seemed to work too well. I figured out this work around using form_alter and custom validation.

Basically, the view filter is expecting term IDs... integer numbers... with autocomplete selected, the view filter gets a text string... so, at form validate I manually explode the string, then create my own tid array. Here's some sample code that worked:


/**
 * Implements hook_form_FORM_ID_alter().
 */
function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  // Alter the exposed filter form.
  if ($form_state['view']->name == 'VIEWNAME') {
    // Add our validation handler.
    $form['#validate'][] = 'MYMODULE_form_views_exposed_form_validate';
  }
}

/**
 * Validation handler.
 */
function MYMODULE_form_views_exposed_form_validate($form, &$form_state) {
  // Get a terms array from the string.
  $terms = explode(',',$form_state['values']['tid']);
  // Init a blank array.
  $form_state['values']['tid'] = array();

  // Go through each term.
  foreach(array_filter($terms) as $term) {
    // Get term objects.
    $t_objs = taxonomy_get_term_by_name($term, 'VOCAB_NAME');
    // We're not sure how many terms will be returned.
    foreach(array_filter($t_objs) as $t_obj) {
      // Let's make sure we have a tid.
      if (!empty($t_obj->tid)) {
        // Add the tid to the values array.
        $form_state['values']['tid'][] = $t_obj->tid;
      }
    }
  }
}