I'm writing my own module for a custom CCK field, and want to define whole widget in the hook_widget() hook only, without using hook_elements() with #process callback. But there is a big problem:

a) If I define my widget as an $element array (for example):

function mymodule_widget() {
  $element = array(
    '#type' => 'textfield',
    '#size' => 25,
    '#element_validate' => array('mymodule_validate'),
    '#attributes' => array('class' => 'text'),
  return $element;

then it doesn't pass value for multiple field to the validation callback (it seems because there is no key in $element array to assign a value).

But if I define my widget as a subkey of the $element array

  $element['value'] = array(

then it doesn't inherit #required, #title, #description and so on values, handled by CCK, because of way a content_field_form() function merges result of mymodule_widget with array of defaults.

So, I want to understand which way is 'right' and how to workaround a respective problem in that case? Or the only 'right' way is to use hook_elements?

P.S. I saw a lot examples of a custom CCK fields in Internet, but most of them use hook_elements, and the rest has a problem with #required/#title inheriting (as a Lullabot example, for example).

Browse other questions tagged or ask your own question.