Index: C:/wamp/www/pega_com/sites/all/modules/contrib/webform_viewreference/viewselect.inc =================================================================== --- C:/wamp/www/pega_com/sites/all/modules/contrib/webform_viewreference/viewselect.inc (revision 327) +++ C:/wamp/www/pega_com/sites/all/modules/contrib/webform_viewreference/viewselect.inc (working copy) @@ -1,5 +1,5 @@ '--'); $all_views = views_get_all_views(); foreach ($all_views as $view) { @@ -68,7 +68,7 @@ '#title' => t('Advanced - Nodes that can be referenced (View)'), '#weight' => -100, ); - + if (count($views) > 1) { $form['extra']['advanced']['advanced_view'] = array( '#type' => 'select', @@ -87,7 +87,7 @@ '#description' => t('Provide a comma separated list of arguments to pass to the view.'), ); } - + $form['value'] = array( '#type' => 'textfield', '#title' => t('Default value'), @@ -97,7 +97,7 @@ '#maxlength' => 256, '#weight' => 0, ); - + $form['extra']['multiple'] = array( '#type' => 'checkbox', '#title' => t('Multiple'), @@ -112,7 +112,7 @@ '#default_value' => $component['extra']['aslist'], '#description' => t('Check this option if you want the select component to be of listbox type instead of radiobuttons or checkboxes.'), ); - + return $form; } @@ -174,10 +174,10 @@ // Convert the user-entered options list into an array. $default_value = $filter ? _webform_filter_values($component['value'], NULL, NULL, NULL, FALSE) : $component['value']; - + $args = $component['extra']['advanced']['advanced_view_args']; $options = _webform_viewselect_options($component['extra']['advanced']['advanced_view'],$args); - + if ($component['extra']['aslist'] === 'Y' && $component['extra']['multiple'] !== 'Y' && !($component['mandatory'] && !empty($component['value']))) { $options = array('' => t('select...')) + $options; } @@ -299,9 +299,9 @@ } else { //$value[$key] = $options[$key]; - $node = node_load($option_value); - if($node) { - $value[$key] = $node->title; + $node = node_load($option_value); + if($node) { + $value[$key] = $node->title; } } } @@ -318,12 +318,12 @@ } } else { // Single value - $node = node_load($value); - if($node) { - $value = $node->title; + $node = node_load($value); + if($node) { + $value = $node->title; } } - + return $value; } @@ -523,7 +523,7 @@ foreach (array_intersect_key($options, $rows) as $key => $label) { $ordered_rows[] = $rows[$key]; } - + // Add a row for any unknown or user-entered values. if ($component['extra']['other_option'] === 'Y') { $full_count = db_result(db_query($count_query, array_merge(array($component['nid'], $component['cid']), $sids))); @@ -630,20 +630,18 @@ * @param $filter * Optional. Whether or not to filter returned values. */ -function _webform_viewselect_options($view,$args = '') { +function _webform_viewselect_options($view,$args = NULL) { $options = array(); - // Prepare field array - Reusing CCK nodreference function _nodereference_potential_references() - $field['advanced_view'] = $view; - $field['advanced_view_args'] = $args; - // Field name used for cid in _nodereference_potential_references - $field['field_name'] = md5($view.$args); - - $data = _nodereference_potential_references($field); - - foreach($data as $index => $row) { - $options[$index] = check_plain($row['title']); + $view_results = module_invoke('views', 'get_view_result', $view, NULL); + + foreach ($view_results as $result) { + reset($result); + $key = current($result); + $label = next($result); + + $options[$key] = check_plain($label); } - + return $options; } \ No newline at end of file