How to implement hook_field_widget_form() for multiple fields? In a module I'm going to implement some Field types using Field API.
this is how hook_field_info() looks like in my module.

function myModule_field_info()
{
  return array(
    'type1' =&gt; array(
      'label' =&gt; t('Custom type 1'),
      'description' =&gt; t('Just for test'),
      'default_widget' =&gt; 'type1_textbox',
      'default_formatter' =&gt; 'type1_rawview',
    ),
    'type2' =&gt; array(
      'label' =&gt; t('Custom type 2'),
      'description' =&gt; t('Just for test'),
      'default_widget' =&gt; 'type2_textbox',
      'default_formatter' =&gt; 'type2_rawview',
    ),
  );
}


and the hook_field_widget_info() implementation is :

function myModule_field_widget_info()
{
  return array(
    'type1_textbox' =&gt; array(
      'label' =&gt; t('Text field'),
      'field types' =&gt; array('type1'),
    ),
    'type2_textbox' =&gt; array(
      'label' =&gt; t('Text field'),
      'field types' =&gt; array('type2'),
    ),
  );
}


off-course this is just an example and each widget has its especial form . now consider that each of my field types has more than one element .


Field type 1


first name
last name

Field type 2


phone number
address
email



now the question is how should I implement widget form for a multiple field type like this?

I tried this code but no chance :

function myModule_field_widget_form(&amp;$form, &amp;$form_state, $field, $instance, $langcode, $items, $delta, $element) {
{
  if($field['cardinality'] == 1){
    $element['#type'] = 'fieldset';
  }
  switch ($instance['widget']['type']) {
    case 'type1_textbox' :
      $type1 = array();
      $type1['firstName'] = array(
        '#type' =&gt; 'textfield',
        '#field_prefix' =&gt; t('First Name : '),
        '#size' =&gt; 20,
        '#default_value' =&gt; isset($items[$delta]['firstName']) ? $items[$delta]['firstName'] : '',
      );
      $type1['lastName'] = array(
        '#type' =&gt; 'textfield',
        '#field_prefix' =&gt; t('Last Name : '),
        '#size' =&gt; 20,
        '#default_value' =&gt; isset($items[$delta]['lastName']) ? $items[$delta]['lastName'] : '',
      );
      $element += $type1;
      break;
    case 'type2_textbox' :
      $type2 = array();
      $type2['phoneNumber'] = array(
        '#type' =&gt; 'textfield',
        '#field_prefix' =&gt; t('Phone Number : '),
        '#size' =&gt; 20,
        '#default_value' =&gt; isset($items[$delta]['phoneNumber']) ? $items[$delta]['phoneNumber'] : '',
      );
      $type2['address'] = array(
        '#type' =&gt; 'textarea',
        '#field_prefix' =&gt; t('Address : '),
        '#size' =&gt; 60,
        '#default_value' =&gt; isset($items[$delta]['address']) ? $items[$delta]['address'] : '',
      );
      $type2['email'] = array(
        '#type' =&gt; 'textfield',
        '#field_prefix' =&gt; t('Email : '),
        '#size' =&gt; 20,
        '#default_value' =&gt; isset($items[$delta]['email']) ? $items[$delta]['type2']['email'] : '',
      );
      $element += $type2;
      break;
  return $element;
}


The code was edited and now no widget is shown in node-edit form and when I went to field management section this error is appearing
the name of the form in   myModule_field_widget_form must be the same column in your  .install file  make sure it matches the same  column