Hi

Im trying to create a combo field, similar to http://www.poplarware.com/cckfieldmodule.html.
Instead I have 2 textfields and 2 datefields, for a resume field. (title, from, until, description).

The problem that I encounter is that it looks like that my process function is not getting called:

In experience_fld.module:

function experience_fld_elements() {
  $elements = array( 'experience_entry' => 
    array(
      '#input' => TRUE,
      '#process' => array( 'experience_fld_widget_process' ),
    ),    
  );
  dpr($elements);
  return $elements;
}

The processor goes through experience_fld_elements() . I can see the array $elements.

And in experience_fld_widget.inc: (there's nop die because it never goes through this function!!)

function experience_fld_widget_process($element, $edit, &$form_state, $form) {
  die(__FUNCTION__);
  $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['from'] = array( 
    '#title' => t( 'From' ),
    '#type' => 'datetime',
    '#default_value' => $defaults['from'],
    '#weight' => 3,
  );

  $element['until'] = array( 
    '#title' => t( 'Until' ),
    '#type' => 'datetime',
    '#default_value' => $defaults['until'],
    '#weight' => 4,
  );

  $element['description'] = array( 
    '#title' => t( 'Description' ),
    '#type' => 'textarea',
    '#default_value' => $defaults['description'],
    '#rows' => 5,
    '#cols' => 40,
    '#weight' => 5,
  );

  return $element;
}

Anybody got a clue?

Comments

nevets’s picture

So you are building a form with the form API and you have an element with '#type' set to 'experience_entry'? What display in the form for that field? Any errors?

eddy147’s picture

No errors...

This is part of a widget.

Im wondering about experience_entry. I thought i could freely give this is a name. Maybe I can not?

Or maybe I should do something like

function experience_fld_elements() {
  $elements = 
    array( 'title' =>
      array(
      '#input' => TRUE,
      '#process' => array( 'experience_fld_widget_title_process' ),
      ),   
      'from' =>
      array(
      '#input' => TRUE,
      '#process' => array( 'experience_fld_widget_from_process' ),
      ),   
      ... //for all my sub fields
  );
  return $elements;
}
nevets’s picture

That would not really help, you want only one element where the processor produces the 4 inputs.

Can you add your field to a content type? Does it show on the edit form?