I have a very complex situation where I need some advice. I have a content type my_content
, which has a field collection field attached to it field_mycollection
, which has an entity reference field referencing to user field_my_userreference
, a phone field field_my_phone
, a text field field_my_text
, and another text field field_my_anothertext
.
My Content
|_ field_mycollection
|_ field_my_userreference
|_ field_my_phone
|_ field_my_text
|_ field_my_anothertext
The user entity has also have fields field_my_phone
, field_my_text
and field_my_yetanothertext
which the latter has a different machine name.
What I want to do, if in my_content
edit/add form, in field_my_userreference
a user is selected, the other fields should be auto-populated from the selected user's data. The auto-populated fields should still be editable.
How could I achieve this goal? I'd like to do it, if possible, with some coding, using hook_form_FORM_ID_alter()
.