Is It Possible Edit to Computed Field?

Events happening in the community are now at Drupal community events on www.drupal.org.
ajajmal006's picture

Hi,
I am using Computed field - CCK in Drupal 6, and i am trying to edit the computed field could some one help me to solve this problem?

Thanks

Comments

What is it you are trying to do?

solveitnow's picture

I will help if I can. Firstly I need to know what it is you are trying to do. Are you trying to use the values from other cck fields to calculate this field?

CCK - Computed

ajajmal006's picture

Hi,

Yes I have a calculation tht " $node[0]['value']=$node->field_buint_family_members[0]['value'] * $node->field_bunit_percentage[0]['value']; " It gives the multiplied value in the Computed field.

And now a user is need to change this computed value while editing the CCK.

A few things to check

solveitnow's picture

When you try this calculation, make sure...

1) that you have the computed field module installed and turned on
2) that the calculated field is of type 'computed'
3) that the calculated field comes after the two fields it requires
4) that the formula is put into the correct area being in the Computed Code area under Global settings
5) that the two field names used in the calculation are exactly right - if not you will get no answer
6) that the display format under Global settings is $display = $node_field_item['value'];

Checked

ajajmal006's picture

Hi,
Thank you very much for your reply, I had checked alll those things that you are mentioned. The computed field is working fine no problem in that,I can get the result.

Say, Multiply is a computed field it have the result as 4*2=8; the value 8 was stored in the database and it was viewed, now what i need is to change the value as 10 while "Edit" the node. I want to edit the Multiply computed field. :)

Thanks

why not a separate field?

fending's picture

ajajmal006 - Would it be reasonable to have an "override field" in the admin to display instead whenever it contains a value? This allows the computed field to do what it does best ("be computed"), and there's no confusion over whether a value was computed incorrectly or overridden (for auditing purposes).

CCK - Computed

ajajmal006's picture

Hi fending ,
Thanks for the reply,I think you asked me to try this module http://drupal.org/project/override_node_options but it does not help me to sort out the problem. is there any other way to edit the computed field like "editablefields" module ?

Thanks

Not quite!

fending's picture

What I was suggesting is that you have another CCK field. Currently,

CCK: $node->field_buint_family_members
CCK: $node->field_bunit_percentage
Computed Field: $node->field_bunit_calc (?)

So what I was saying was DO NOT override the field, but instead have:

CCK: $node->field_buint_calc_override

...and instead of trying to reinvent the wheel by overriding a calculated field, use a preprocessor to evaluate whether $node->field_buint_calc_override has a value and, if it does, present it instead of the calculated field in the last mile.

As an example, check out this content type I threw together:

http://brianfending.com/content/testing-node

it's Field A, Field B, a computed field, and a Calculation Override field.

The first, second, and last of those are editable fields in the content type, see image link on the above node. What I'm saying is that you could preprocess whether or not the computed field or the override is presented, based on whether or not "calculation override" field has a value.

And if you need to control who has access to edit that particular (override) field, there's a module for that, I believe.

Content Construction Kit (CCK)

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week