Closed (fixed)
Project:
Computed Field
Version:
4.7.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
29 Sep 2006 at 04:06 UTC
Updated:
2 Oct 2006 at 10:57 UTC
I'm having trouble with a computed field that I want to be a text value.
Later I plan to add some actual logic to set the value, but for now, all I have is
Required: not checked
Multiple values: not checked
Computed Code: $node_field[0]['value'] = "RESERVED";
Display this field: checked.
Display Format: $display = "Status: " . $node_field_item['value'];
Store using the database settings below: checked
Data Type: text (also tried varchar)
Data Length:
Default Value:
Not NULL: unchecked
Sortable : checked
All I see is:
Status:
Thanks
Comments
Comment #1
skor commentedAlso tried
Data Length: 64
with both varchar and text.
Comment #2
wrunt commentedHi Skor,
Have you tried editing and saving the node you're testing with? The value will only be computed on save. For something short like that I'd probably go for varchar with data length 64. The data length is needed.
Comment #3
skor commentedthanks for the quick response.
Good thought, I hadn't been re-saving, but even when I made some changes and saved, it didn't show up.
Comment #4
skor commentedlooking at phpmyadmin, there doesn't appear to be a row for this field in the database
fyi, using Drupal 4.7.3, MySQL 4.1.21
// $Id: computed_field.module,v 1.1.2.11 2006/09/15 00:39:28 wrunt Exp $
// $Id: content.module,v 1.56.2.20 2006/09/19 00:41:42 JonBob Exp $
Comment #5
skor commentedOk, if I create a computed field, and make it an int, I get a row in the database. And then, if I go set the type to varchar, the type in the database stays int.
Not sure yet if the problem is in computed field, or CCK, but I'm pretty sure it's a bug.
Comment #6
skor commentedand at some point, shouldn't I have gotten this warning for a blank data length?
Ok, I'm tired and I'm mixing issues. Here's what I've got so far:
Comment #7
wrunt commentedI'll take a look at this tonight. I've been meaning to add validation to that part of the form, and since it's been a problem for at least one person I guess I'd better do it.
As for your main problem, I'm not sure what's going on. The database_columns return of one of the cck hooks should be used by cck to change the data type, so if you change it then cck should change it. Maybe the bug has been introduced in the latest cck release, which I haven't tested with. I'll see if I can reproduce the bug tonight as well.
Comment #8
wrunt commentedI've had a play on a fresh install with the same version of cck and computed field that you used. I didn't get any errors.
I created a new content type called 'test computed field'. I gave the content type one computed field. I gave the computed field the same settings as you did, using varchar 64. I created a new node using my new content type and 'Status: RESERVED' showed up as expected.
Next I tried changing the field's data type to int, and checked that the data type of the computed field in the node_content_test_computed_field table had changed. I changed it back to varchar and again the data type changed.
What database are you using? Maybe the permissions aren't set up right? If you don't have the ALTER permission then that may cause the error you're getting.
Comment #9
wrunt commentedI've fixed the validation of data length. You shouldn't be able to submit an empty data length if storing the field in the database. This shouldn't actually have caused a problem before, because the code dealt with an empty data length by setting it to a default of 32.
Comment #10
skor commentedI'm using Mysql 4.1.21 with Drupal 4.7.3 and the userid for the database has all privileges that Cpanel offers: SELECT, CREATE, INSERT, ALTER, UPDATE, DROP, DELETE, LOCK TABLES, INDEX, REFERENCES, CREATE TEMPORARY TABLES.
I'll try it on a fresh 4.7.3 install tomorrow, in case there's something corrupted with this one.
Comment #11
skor commentedOK, I tried it on my production site (finally upgraded my events from flexinode to CCK).
Everything worked just fine. Hope I didn't waste too much of your time on this.
I'd been playing around on the development site for quite a while since I last re-synced to the primary database. I'll re-sync it, and try it out again. Hopefully it will go away.
Thanks again.
Comment #12
wrunt commentedCool, I'm glad you worked it out. I got drupal working on my mac and fixed a few bugs, so no time wasted here.