1

I have created a file field with field_create_field() and added an instance of it to my custom node type with field_create_instance() in my module's hook_install()function. But how do I set it to allow unlimited file uploads. I can do it in the drupal interface by going to structure > content types > manage fields and clicking edit for my file field. I can set number of values on that page but how do I do it programmatically? There must some settings key I suppose but could not find it online.

I am using drupal 7.

2

my example, see "cardinality" value:

$field = array(
  'field_name' => 'field_ws_file', 
  'type' => 'file',
  'cardinality' => FIELD_CARDINALITY_UNLIMITED,
);
field_create_field($field);

Instead of FIELD_CARDINALITY_UNLIMITED you could also simply use -1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.