How to force a field to allow unlimited number of values using Field API? How do I force an unlimited number of values using code for a field I created using the Field API in Drupal 7? In this case it doesn't make sense to have any other setting so every time I create an instance of this field I have to set the number of values from 1 to unlimited.
You mean for a field type that you created yourself?

There is no real API to declare that, the only thing you can do is alter the add/edit field form.

I've already done this myself for the Properties module; here is the code (source):

function properties_form_field_ui_field_edit_form_alter(&amp;$form, &amp;$form_state) {
  if ($form['#field']['type'] == 'properties') {
    // Hide the cardinality setting on the field settings for properties fields.
    $form['field']['cardinality']['#default_value'] = FIELD_CARDINALITY_UNLIMITED;
    $form['field']['#access'] = FALSE;
  }
}


(Don't forget to flush the cache after changing form_alter hooks and, if it's an instance setting, delete and recreate the instance to remove the previous default)