How to override default cardinality for the field widget? I've custom widget which consist multiple input elements in hook_field_widget_form() as part of one field (like address field).

The problem is that Drupal complains about:


  this field cannot hold more than @count values


which happens in field_default_validate(), when I've multiple input filled, so it doesn't recognise that this is one single field.

I've tried to change my cardinality in every possible place as below, but without success:

/** 
 * Implements hook_field_info().
 */ 
function my_address_field_field_info() {
  return [
    'my_address_field' =&gt; [
      'label' =&gt; t('My Address Field'),
      'settings' =&gt; array('cardinality' =&gt; FIELD_CARDINALITY_UNLIMITED),
      'instance_settings' =&gt; array('cardinality' =&gt; FIELD_CARDINALITY_UNLIMITED),
      'default_widget' =&gt; 'my_address_field_widget',
      'default_formatter' =&gt; 'my_address_field_default',
      'cardinality' =&gt; FIELD_CARDINALITY_UNLIMITED,
    ],
  ];    
}

/**
 * Implements hook_field_widget_info().
 */
function my_address_field_field_widget_info() {
  return [
    'my_address_field_widget' =&gt; [
      'label' =&gt; t('Default'),
      'field types' =&gt; ['my_address_field'],
      'settings' =&gt; array(
        'size' =&gt; 60,
        'cardinality' =&gt; FIELD_CARDINALITY_UNLIMITED,
      ),
      'behaviors' =&gt; array(
        'multiple values' =&gt; FIELD_BEHAVIOR_NONE,
        'default value' =&gt; FIELD_BEHAVIOR_NONE,
      ),
      'cardinality' =&gt; FIELD_CARDINALITY_UNLIMITED,
    ],
  ];  
}

/**
 * Implements hook_field_widget_properties_alter().
 */
function my_address_field_field_widget_properties_alter(&amp;$widget, $context) {
  $widget['cardinality'] = FIELD_CARDINALITY_UNLIMITED;
}

/**
 * Implements hook_field_formatter_info().
 */
function my_address_field_field_formatter_info() {
  return [
    'my_address_field_default' =&gt; [
      'label' =&gt; t('Default'),
      'field types' =&gt; ['my_address_field'],
      'multiple values' =&gt; FIELD_BEHAVIOR_DEFAULT,
    ],
  ];
}

/**
 * Implements hook_field_widget_form().
 */
function my_address_field_field_widget_form(&amp;$form, &amp;$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  $widget = array();
  $widget['label'] = array(
    '#title' =&gt; $instance['label'],
    '#theme' =&gt; 'form_element_label',
  );
  $widget['address_line_1'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Address line 1'),
  );
  $widget['address_line_2'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Address line 2'),
  );
  // more text fields here ...

  return $widget;
}


Including defining hook_field_validate which I thought it'll override default field validation handler, but this was not the case.

What's the right way of assigning unlimited cardinality for my widget?
You can use Field instance cardinality module which allows the cardinality of specific instances of fields to be overridden.

This module allows the cardinality of specific instances of fields to be overridden.
This currently only works with fields that use options widgets (ie select list or checkboxes), and only allows them to be overridden to be single-valued.