[development] Reusing elements in a compound CCK field

Yuval Hager yuval at avramzon.net
Tue Jun 30 06:33:22 UTC 2009

On Tuesday 30 June 2009, Bill Fitzgerald wrote:
> Have you seen http://drupal.org/node/119102 ? -- you might want to skip
> to the second page and only read comments 301-600  --

I've seen this in the past, but was happy to find out it was committed 
finally into CCK. Thanks for the pointer!

I tested this briefly and it seem to work quite nicely. Although it doesn't 
comply with the "same record for all fields" requirement, I can use a 
simple JOIN (both on vid and delta) to overcome this.
What is the status of this code? Building a site on not-released code can be 
quite frustrating (underlying changes, untested, upgrade path), and I 
prefer not to go that route if possible.

My application is going to be centered around this data, and it should go 
into production soon - I wonder whether I should build it around content 
multigroup, or write my own - which will have less features, but I will 
have more control on, and better table structure (and thus my original 
question about the implementation).

> You could also check out http://drupal.org/project/education_field and
> http://drupal.org/project/employment_field, although the approach used
> in the patch will likely allow more options over time.

These are both for D5, and the author abandoned efforts to port these to D6. 
I think there are more cases like this.


> Cheers,
> Bill
> Yuval Hager wrote:
> > 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

Yuval Hager
[T] +972-77-341-4155
[@] yuval at avramzon.net
-------------- 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/0a3ddcc2/attachment.pgp>

More information about the development mailing list