When references view is selected in field settings form and select list widget as fallback it shows <span class="views-field views-field-title"> <span class="field-content"> [title] </span></span> as drop down options.
bug.png
Related issue #1860696: References user views fallback select list widget shows views html in options

CommentFileSizeAuthor
views_fallback_select_list_error.patch1.15 KBjibran
bug.png2.71 KBjibran

Comments

gerson.analista’s picture

Thank's jibran,

I tried use your path, but when i choose "Grouping field Nr.1" in "References: Style options" it gererate one error.

I aplied this changes and work...

diff --git a/nodereference_url.module b/nodereference_url.module
index 0ef5dcb..0e6ad21 100644
--- a/nodereference_url.module
+++ b/nodereference_url.module
@@ -65,7 +65,7 @@ function nodereference_url_node_view($node, $view_mode, $langcode) {
  * @param $node
  *   A fully loaded node object.
  * @param $teaser
- *   
+ *
  * @return
  *   An array of links for use with theme_links().
  */
@@ -426,10 +426,25 @@ function nodereference_url_field_widget_form(&$form, &$form_state, $field, $inst
     }
     // Fallback to select list.
     elseif ($fallback == 'select') {
+      $options = node_reference_options_list($field);
+      if (module_exists('views') && !empty($field['settings']['view']['view_name'])) {
+        foreach ($options as $key => $value) {
+          if(is_array($value)){
+             foreach ($value as $k => $v) {
+               if(is_string($v)){
+                  $value[$k]= strip_tags($v);
+               }
+             }
+          }elseif(is_string($value)){
+              $value = strip_tags($value);
+          }
+           $options[$key] = $value;
+        }
+      }
       $element += array(
         '#type' => 'select',
         '#default_value' => isset($items[$delta]['nid']) ? $items[$delta]['nid'] : NULL,
-        '#options' => array('' => t('- None -')) + node_reference_options_list($field),
+        '#options' => array('' => t('- None -')) + $options,
       );
     }
     // Fallback to autocomplete.
spacer’s picture

Thanks Gerson - patch in #1 works fine.

I'm not too sure what the first part of the patch does - this failed when I applied it 'patch unexpectedly ends in middle of line', but the second part applied fine and the dropdown list appears as it should do.