2
votes

This question is basically a follow-up to this one:

Drupal Custom CCK field with multiple child fields

I need to build a CCK field type that stores several pieces of data, and fAPI form elements to accept the input for each piece of data already exist. These elements are built out into multiple HTML form inputs with fAPI #process functions. The problem is that when I try to use these elements in my CCK field, the input from the widget doesn't line up with the database columns specified in hook_field_settings(). The widget returns something like this:

Array (
  [thumbnail_image] =>
    [imceimage_path] => ...
    [imceimage_alt] => ...
    [imceimage_width]  => ...
    [imceimage_height]  => ...
  [user_address] =>
    [address_number] => ...
    [address_street] => ...
    [address_city] => ...
    [address_state] => ...

Unless there's a way to specify "sub-columns" in hook_field_settings(), it appears to me that I can't use form element types with sub-elements in CCK fields. I've tried using CCK field validation to pull out the "imce_xxx" values from thumbnail_image and likewise with user_address, but that doesn't get me anywhere.

Is it not possible to use form elements with child elements in CCK field definitions?

Thanks,
Cliff Smith

1
What are the specified database columns, and what do you mean with 'the input [...] doesn't line up'?Henrik Opel
My CCK field type needs to accept an FLV and a still image from that FLV. I'm using an imceimage element to accept the image, and I've got a stripped-down clone of imceimage called imcefile that's removes the image-specific language and the preview version of the image. Its only form value is called imcefile_path: $element['imcefile_path'] = array( '#type' => 'hidden', '#id' => "imcefilepath-$delta-$field_id", '#default_value' => $value['imcefile_path'], );bismuthsalamander
The columns in my CCK field are imcefile_path and the four columns from imceimage (imceimage_path, imceimage_width, imceimage_height and imceimage_alt). Here's the widget: $element['video_file'] = array( '#type' => 'imcefile', ); $element['still_image'] = array( '#type' => 'imceimage', );bismuthsalamander
When I look at the form elements on the node form, they've got extra brackets in the name attributes, such as field_video[0][video_file][imcefile_path] and field_video[0][still_image][imceimage_alt] instead of field_video[0][imceimage_alt]. That's what I meant by the fields not lining up - the fields aren't named in such a way that CCK will map the post data to the right columns.bismuthsalamander

1 Answers

0
votes

CCK 3 -dev version has nice new feature called Nested Fieldgroups. It allows you to create fieldgroup and add fields to it. in node you can then add new fieldgroups with same set of fields in each. Views 3 -dev allows to group and display these fieldgroups.