Hi all and sorry for my language

I create "User" display in Drupal 6.15 Views 6.x-2.8. Then i create different types of profile fields in it and all fields values displays on user profile page normally but value of field "freeform list" is always empty on several Drupal projects. Value of this freeform list field shows up perfectly in Panels 6.x-3.2. How i can display this freeform list field in Views? Thank you.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ad_Astra’s picture

Title: Value of custom profile field "freeform list" in views » seems to be slightly broken by its developers
Priority: Normal » Critical
Status: Active » Needs review
FileSize
988 bytes

Got the same problem today. After messing with all that code for some hours, I found that a class in the file /modules/views/modules/profile/views_handler_field_profile_list.inc has a weirdly looking 'pre_render' method that has no foreach over the arguments array and doesn't return anything. I fixed it, and also commented out the 'render_item' method that gives an error (had no time to look why, sorry). If you look into the attachment to this comment, you'll see something that at least works.

Ad_Astra’s picture

Title: seems to be slightly broken by its developers » Freeform list support seems to be slightly broken by its developers
Ad_Astra’s picture

Category: support » bug
dagmar’s picture

Status: Needs review » Needs work

Sorry you didn't provide a patch.

merlinofchaos’s picture

Status: Needs work » Active

Active is better for "no patch attached" state.

Ad_Astra’s picture

Status: Active » Needs review
FileSize
1.03 KB

Sorry, i'm quite a noob here, didn't know about those proper patch formats. now there is a patch in the attachment.

hop242’s picture

It works fine. Thank you so much Ad_Astra.

dagmar’s picture

Version: 6.x-2.8 » 6.x-2.x-dev
Priority: Critical » Normal
Status: Needs review » Needs work
Issue tags: -views, -field, -profile, -list, -value
+++ modules/profile/views_handler_field_profile_list.inc.txt	2010-01-08 04:24:07.000000000 +0300
@@ -8,18 +8,22 @@ class views_handler_field_profile_list e
+    foreach ($values as $value) {

If you add a new foreach, you should identate all the code inside it.

+++ modules/profile/views_handler_field_profile_list.inc.txt	2010-01-08 04:24:07.000000000 +0300
@@ -8,18 +8,22 @@ class views_handler_field_profile_list e
-  function render_item($count, $item) {
-    return $item['item'];
-  }
+  //function render_item($count, $item) {
+  //  return $item['item'];
+  //}

If you are removing a function, please, explain in the issue, why you are removing it, and don't comment the lines, simple, remove it.

Changing, status, removing all these not useful tags.

Ad_Astra’s picture

Status: Needs work » Needs review
FileSize
1.07 KB

fixed the patch.

so, why I removed that method. after I studied the structure of the array called '$values' used as an argument by 'pre_render()' and fixed the foreach issue, that 'render_item' method started giving me an error. I figured out that there is a check for 'render_item' method in the class, and if this method is not present, it's rendered some other way that actually worked (and, as I said before, I had no time to dig deeper, sorry). so I removed $this->items[$field]['item'] (replacing it with $this->items[$field][]) and this method.

merlinofchaos’s picture

Status: Needs review » Needs work

While it looks like you're right that perhaps the looping is wrong, the removal of render_item() is wrong. I believe that needs to be in there to allow the rewrite to work the way it is supposed to on grouped items.

trjohnson’s picture

Same issue here.

The patch provided by Ad_Astra only returns the first row in the view. The subsequent rows still do not return a value. We've rolled back the file to the previous release and it has begun working once again.

Aside from the addition of the token values, what reason is there behind the other changes in the code?

peck66’s picture

Thanks for all your work on this guys.

Is Ad_Astra's patch returning the result "return parent::pre_render($value);" in the correct loop level?
I had _some_ extra success by shifting the return out one level - but I am very much a hacker and can't take it further at this stage.

peck66’s picture

Status: Needs work » Needs review
FileSize
876 bytes

This patch seems to work - and it doesn't remove the render_item() function.

peck66’s picture

Same patch - better name.

dagmar’s picture

+++ modules\profile\views_handler_field_profile_list.inc	Sun Feb 21 17:45:19 2010
@@ -8,11 +8,14 @@ class views_handler_field_profile_list e
+        if ($item != '' && $item !== NULL) {

This code could be replaced by:

if (!empty($item)) { 

isn't?

peck66’s picture

Thnx for the review, dagmar :)

The item test you speak of was original code, so I didn't want to change it ...

http://php.net/manual/en/function.empty.php
says ...

The following things are considered to be empty:

"" (an empty string)
0 (0 as an integer)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)

I think someone might like
"0" (0 as a string)
to be a valid list entry, so perhaps it is better as it is?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I think peck66 made a good argument, why this should be kept as in current code.

The current code is definitive total broken: $value is not set in that context.

Without manual testing just looking at the code, it looks fine.
PS: This would make http://drupal.org/node/420850 active again, because i removed the check for "," there.

The rest looks really fine

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed to all branches. Thanks!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev

I'm experiencing trouble with the freeforms in views, this time in Drupal 7. It displays well when I ask views to show the complete user, but when I use fields, nothing appears.

I sometimes get this message :
Warning : Illegal offset type dans views_handler_field_profile_list->pre_render() (line 21 in [path_to_drupal]/sites/all/modules/views/modules/profile/views_handler_field_profile_list.inc).
So I wandered a bit in the php code, and I found the function a bit strange, but I'm not an expert : $this->items is set to an empty array in pre_render(). Then it calls get_values(), declared in the class views_handler_field_prerender_list (its parent), which calls get_items(). And get_items() asks for $this->items[$field], whereas $this->items is still empty...

But perhaps it just comes from a wrong configuration either in profiles or in views.

dagmar’s picture

Pozzo: Please fill a new issue following the Views issue submission guidelines. Thanks.