Custom CCK type with WYSIWYG editor

Events happening in the community are now at Drupal community events on www.drupal.org.
wvrent's picture

Has anyone got experience with creating custom multipart CCK fields in Drupal 6?

I'm creating a custom field (titleandbody_fld) that has a Text field and a Textarea field with unlimited values. The Textarea is (by default) HTML with WYSIWYG turned on.

When creating new content, the titleandbody_fld appears with two blank instances, everything looks right and functions ok, but if I add another instance, the data is lost on the last field and the existing fields revert to no WYSIWYG mode.

I've determined that at least one of my problems is likely in the _entry_process callback, likely something to do with a "format" value, but I'm not certain where to place it.

This is what I currently have:

function titleandbody_fld_titleandbody_entry_process($element, $edit, &$form_state, $form) {

  $defaults = $element['#value'];
  $field = content_fields($element['#field_name'], $element['#type_name']);

  $element['title'] = array(
    '#title' => t('Title'),
    '#type' => 'textfield',
    '#default_value' => $defaults['title'],
    '#weight' => 2,
  );

  $element['body'] = array(
    '#title' => t( 'Body' ),
    '#type' => 'textarea',
    '#rows' => $field['widget']['rows'],
    '#cols' => $field['widget']['cols'],
    '#default_value' => $defaults['body'],
    '#weight' => 3,
  );

  return $element;
}

London, Ontario

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: