I have a Products taxonomy with all possible product names offered by the organization, Order content type to place an order and ordering form. Order content type includes field collection with term reference field referencing to Product taxonomy. The case is that I need to predefine field collection items with all possible selected Product terms on ordering form. Items number = count(Products terms)

I tried to use field_multiple_value_form function to generate items, but in this case I can't predefine default value for field inside field collection item (or can?).

$products_taxonomy = taxonomy_vocabulary_machine_name_load('products');
$product_tree = taxonomy_get_tree($products_taxonomy->vid);

if (is_array($product_tree)) {
  $field_instance = field_info_instance('node', 'field_fc_o_position', 'order_request');
  $field_instance['cardinality'] = count($product_tree);
  $field_instance['type'] = 'field_collection_item';
  $field_instance['columns'] = array();

  $form_state['field']['field_fc_o_position'][LANGUAGE_NONE]['items_count'] = count($product_tree);
  $instance = $form_state['field']['field_fc_o_position'][LANGUAGE_NONE]['instance'];

  $form['field_fc_o_position'][LANGUAGE_NONE] = field_multiple_value_form(

Question is how to generate empty field collection items on ordering form and default value for select field inside each new item?

Thank you!

1 Answer 1


I do not think that this will work in the way you wish, since Field Collections are entities rather than normal fields.

It sounds to me like you need to use form_alter to update your input form.

Checkout this link on Drupal.org for one method that might work: Finally - found a solution... (D7)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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