I've created a content type, and added a computed field to it, but I cannot see it in the page node.

For the "Computed Code" I have just one commented out line: //$entity_field[0]['value'] = "blah";

In the "Display Code" as a test I simply have:
$display_output = "hellooooo";

I figure this would be enough to see *something* on a node page for that content type. But I get nothing.

I've set it the computed field to "Required", no change.

I have gone to the content type "Manage Display" tab and made sure all the fields are set to be shown. For the Computed Field display settings, I have cycled through "Unsanitized", "Plain Text", "Filtered Markup", "Raw Value" with no success.

I changed the display weight of the Computed Field to be between some existing fields, and investigating with Firefox on the rendered node page, I see no new div between the other fields, so it doesn't seem to be making it to the rendered node page.

Looking at phpmyadmin, I see activity in the table "field_config" every time I change the computed field display code, changing "$display_output = "hellooooo";" to something else like "$display_output = "3214098723872345";". This tells me the computed field settings are being saved to my DB.

I have no theme file for this content type. Actually no theme files PERIOD yet. The node page is not being touched by anything else, there are no Views or Blocks involved.

Now I'm at a loss and posting here =P. Maybe I'm overlooking something obvious.

Comments

shanethehat’s picture

I'm trying a similar approach using a plain string as the value for $display_output. The view is outputting the wrapper HTML, but no value.

cn313’s picture

Ok guys, had the same problem (with Drupal Version 6)

You have to make sure to switch the 'Computed Code' from rich text editor to plain text editor (click on the link below, ckeditor) and then enter your code, otherwise the editor will automatically add some html tags. Same goes for 'Display Format'

Hope this works for you.

Greetz

Cablestein’s picture

Hey, that sounds plausible.

Are you referring to the format selection in Display Fields?

For D7, I see:
Unsanitized
Plain text
Filtered Markup
Raw value, no display code

I've cycled through them all with still no output.

Should I be looking somewhere else, or maybe the D6 version is different?

Can you give more detailed steps?

ajisree’s picture

Hi,

I face the same issue. Enabled php, permissions given, text format is "unsanitized" still the computed field does not display. I am trying to add an additional field to Ubercart product.

Any help will be greatly appreciated.

http://knowmykerala.in

ajisree’s picture

Hi,

Think I got the solution. The text format needs to be "plain text" else this won't be displayed. Still face a few other issues regards to fields, but hope to sort it out.

Thanks,

http://knowmykerala.in

gaborpeter’s picture

I had the same issue.
In my case, I use Organic Groups, and I had to set the field permissions there as well.
Maybe this is not the case on your side, however you can debug backtrace if your field has #access = TRUE granted.
If not, you can check which module is setting your field permission in the fiel field.module under the field_access function.

Cablestein’s picture

I have no users, just myself the original admin. Logged in, no permissions should limit me. Just in case, anyways, I've checked all permissions ON for the admin role.

Still no resolution to the issue.

Cablestein’s picture

FOUND THE PROBLEM, hooray

Display output on the node page works as soon as I unchecked "Store value in the database" in the Computed Field settings (in my troubleshooting I must have always overlooked this option).

I probably checked this box in the beginning when I first started using Computed Fields, because my intention was to use this with Views, and the message on the check box mentions you need it ON for Views. Although I can't confirm it, my feeling is the very first time I checked this box, I may have had empty output (for some reason), and viewed the node. Then the empty result got saved to the DB and has been there ever since, until I unchecked the box.

The checkbox message contains this "... will only be recalculated when the entity is updated.", which I believe is the key to this whole situation. How does the entity get updated? Does it just mean changing the computed code? Can the cache of db-saved computed outputs be cleared somehow, like clear cache?

maxchock’s picture

any progress on your issue?? I'm facing similar problem as you. I need the value to be automatic calculated and store into database..

windmaomao’s picture

i got it working following #8 comment. I have to disable that option "Store using the database settings below (required for Views use)"

but i thought this option shouldn't have anything to do with display ? am i wrong ? so either i want to store or display ? can't do both.

thank you.

windmaomao’s picture

i think i know what's going on here :)

you need to add or save the node again to populate the computed field, this should be obvious if someone installed the module before adding nodes.

maxchock’s picture

i tested resave with changing the value also no luck.. can you show me your code here?? thanks.

maxchock’s picture

i tested resave with changing the value also no luck.. can you show me your code here?? thanks.

skipyT’s picture

Status: Active » Closed (cannot reproduce)

Hi,

I'm using the computed field module in several projects and on more than one entity type and nodes also and it is working perfectly for me.

Computed field module is behaving differently based on the field settings.
If the option to store the field value is checked, then the value of the field is computed before the entity save and saved. And on entity load the value is loaded from the storage.

If the user chooses to not store the value, the value will be calculated on every entity load if entity field cache is not activated. If cache is active the value will be calculated only if the entity is not cached (but this is obvious).

EmmyS’s picture

Status: Closed (cannot reproduce) » Active

I'm running into the same issue, along with several others. I do have the Save to Database box checked, because I need to use the field in a View. But it doesn't appear to be saving the actual value, although a record is being created in the database.

mloigeret’s picture

I have kind of a similar issue:
a computed field is not displayed in a view result but it works as a filter criteria for the same view.
I created another issue for that here http://drupal.org/node/1729038

Anonymous’s picture

I have same proplem. No output from computed field. Also not by $display_output= "hello"; (with unchecked database box)

Anonymous’s picture

Issue summary: View changes

Update