I have a small working node module written in code, which build its form using the Form API fields.

The question is, can I also add CCK fields to this form? Can I mix FAPI and CCK fields? If not, can I code using CCK-only fields? In particular, I would like to use the Date field from CCK, with its calendar popup. The other fields seem equivalent to me (so far:).

I know I can add CCK fields using the Admin Interface, but I need to use code to implement the functionality of the node. Perhaps I can add the CCK fields through Admin Interface, then retrieve/update the fields in code somehow?

Is there sample code somewhere showing how to do this? I have been searching, but haven't found anything yet.

Thanks,
brew

Comments

nevets’s picture

I don't know of a document but I can give you a hint, in the source file for a field type look for hook_elements (hook will be the module name as usual). If you look at number.module you will find

function number_elements() {
  return array(
    'number' => array(
      '#input' => TRUE,
      '#columns' => array('value'), '#delta' => 0,
      '#process' => array('number_process'),
    ),
  );
}

If the sub array has #input set to TRUE the key (in this case 'number') corresponds to form API type (#type). I have not played with this further though to give you more of hint.