I have a form with field collections; on form validation I need to add instances of that field collection type. For example, field collection user_data has fields first_name, Last_name; when someone submits the form, I want to add as many fist_name and last_names as I want, programmatically. The field collection user_data is set as unlimited.

I was thinking to something like the following.

// Create new field collection item of type user_data
// Set first_name, last_name
// Append field collection item to $form some how

I'm just not sure how to do this, or even if it's possible.

  • a form (a Form API form) is not a drupal Field API widget. A field collection is a Field used in an Entity, not a simple HTML form. – tenken Jan 24 '14 at 18:31
  • I'm using Entityforms with an embedded field collections field. – rudy2342 Jan 24 '14 at 19:37

Your Answer

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

Browse other questions tagged or ask your own question.