[development] Reusing elements in a compound CCK field

Yuval Hager yuval at avramzon.net
Tue Jun 30 04:29:44 UTC 2009


I am writing an application in which I need a compound cck field - a 
nodereference and a numerical value. The underlying database table MUST 
keep both values in the same record (no "delta" based value matching, like 
CCK multigroup does), so I reverted to writing my own CCK compound field 
module.

However, I am having a hard time understanding if I can reuse the elements 
declared by the nodereference and the number module for my case. I am 
trying, for example, to use '#type' => 'nodereference_autocomplete' in my 
element #process function, but maybe I do not need to define an element at 
all? Maybe I should just use it in hook_widget? Also, How can I convince 
nodereference and number to work on MY definition of #columns? This goes 
for validation, autocompletion and value (stripping out the "[nid:]"). I am 
not finding good documentation for this, and the code for other modules who 
do similar stuff is rather confusing (I looked at a few). Before I revert 
to voodoo or code duplication - can anybody shed some light on the subject?
If needed, I can paste my (non working) code here.

There are a few documentation points for this on the net - the best I've 
found is http://poplarware.com/cckfieldmodule.html by Jennifer Hodgdon. 
Thank you Jennifer, this is a great guide. However, this guide delegates a 
lot of functionality to filefield/imagefield, and my case is quite 
different. CCK documentation on these hooks is rather laconic, or not up to 
date with the latest version.

This also makes me wonder if one can write a generic compound CCK field 
module, that will allow the user to reuse existing fields and build a new 
one using the UI only. But first things first - the specific case should 
work before the generic one :)

Cheers,

--yhager

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.drupal.org/pipermail/development/attachments/20090630/487fa883/attachment.pgp>


More information about the development mailing list