When I look at CCK field data, very often the field has multiple attributes for each field item. For instance (using Devel's Dev Load node inspector):

field_portfolio_image (Array, 1 element)
- 0 (Array, 3 elements)
- - fid (String, 3 characters ) 370
- - uid (String, 1 characters ) 1
- - data (Array, 2 elements)
- - - description (String, 0 characters )
- - - alt (String, 0 characters )

This field has many different attributes and values (even nested arrays with more values) for each item.

With a CF field, while I can create multiple items, each item is limited to a single attribiute: 'value:'

field_computed_youtube (Array, 1 element)
- 0 (Array, 1 element)
- - value (String, 27 characters ) http://youtu.be/xxxxxxxx

I've even set additional attributes in the CF PHP field, like this:

$node_field[0]['title'] = "Title of Video";
$node_field[0]['width'] = "600px";
$node_field[0]['height'] = "400px";
$node_field[0]['value'] = $url;

But when the node is saved only the 'value' attribute is written to the node (see output above).

Why can't we use this module to set other attributes? Am I missing something? I've seen no examples where people attempt to do this, so perhaps this module cannot handle writing more than a single value to a field item...

Any thoughts?

Update/Workaround:

Still couldn't find anything that forces Computed Field to hold anything besides the single 'value' attribute, but I did find that...

  1. serializing an associative array like the example code above,
  2. setting that serialized string as the ['value'] value,
  3. and using the Computed Field Display override function to unserialize and access that array works.

It's very unwieldy though, and I'm still interested in any clean-cut solutions or patches.

Comments

amaisano’s picture

Issue summary: View changes

Generalized code snippet

jay-dee-ess’s picture

Version: 6.x-1.0 » 7.x-1.0-beta1

+1 (for 7.x)

I'm hoping to use Computed Fields in combination with Views Autocomplete. That module needs a "safe_value" element. I'd love to be able to make it all work without having to hack either module.

cmsdave’s picture

subscribing

colan’s picture

@cmsdave: There is no longer any need for "subscribing" comments. Simply click the "Follow" button at the top of the issue.

colan’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev

Forgot to add that new features go into the latest dev branch.

colan’s picture

Issue summary: View changes

Update/workaround discovered.