I have three content types :
- Classroom (some fields)
- Student (some fields and one EntityReference to Classroom)
- KMDone (some fields and a FieldCollection)
KMDone is a content type which contains : - a date - a FieldCollection "kmdone_students"
The FieldCollection "kmdone_students" contains itself - an EntityReference to the Student - a distance "go" (Numeric fied) - a distance "back" (Numeric fied)
Everything works fine except one point :
The generated form for the KMDone content-type requires to click several times on the "Add More" button to have enough rows for every student, choose one student on each select of each row, and then fill the form. Which is not confortable and can give some encoding errors due to user.
So, I would like to alter the form and prepopulate one "row" for each student.
It seems I have to work with the hook_form_alter
hook, but how can I can I prepopulate one "row" in the FieldCollection (as if the user clicked on "Add more" button) for each EntityReference ?
To say it in other words : if the original form SelectBox have 17 students, I would like then to prepopulate 17 rows and set the EntityReference field for each student.
Many thanks in advance for your tips !
Kind regards,