Posted by SseggembeMoses on March 27, 2015 at 2:01pm
Is there anyone who knows how to auto populate data from an entity reference into another content type fields.
Say i have two content types. school and registration form.
So how can i pull data from the schools content type(such as name, location, headmaster etc) into the registration form when a user selects a school in the form as a reference?
I have used entity reference and auto fill modules but i cant get them t work.
Anyone with ideas?
Comments
Why would you want to do
Why would you want to do that? When you display the data later (or export it) with views, you can easily display the school data again. Just selecting the school to the form should be enough.
Otherwise, you could look at https://www.drupal.org/project/prepopulate
Hello, what i want to do is
Hello, what i want to do is that, when a some one is filling the form(content type), say he selects the name of the school, then the other fields such location, contact are filled in automatically into fields defined in the registration form.
I have looked at prepopulate but it doesnt do it.
Thanks
Tech-256
I would propose ...
I agree with batje. It does not make sense for you to repeat the addition of the school location data onto a related entity. It is already captured with the school. Based on this relationship, the fields you want to fill should not even appear on the secondary entity.
I also do not understand how "registration form" is a content type. Perhaps, you could give more details.
But to answer your question, I would assume the following:
Proposed Solution
This would be the way that I would approach this. There might be a better way.
Still, like batje said, the fields on the school's parent entity should be only for display purposes and should not be actually attached to the parent entity.
Good luck! Hope that makes sense. Let me know if you need any clarification.
Thanks for your solution lwanga.
Thanks for your support. Your solution is solid, but however i managed to do it using Entityreference Autofill module.
Tech-256
Excellent!
Excellent!
Same question
Hi, I have to do the same thing, because the user should have the possibility to modify the fields autofilled with the module.
SseggembeMoses, were you able to do that with Autofill?
Thanks in advance
Ric
Yes i managed to do it
Say you want DOB, Age, Height, email address to be auto filled when you select a Person's name.
1. create a content type(to be referenced by another content type) say "person"
2. Add the required fields. example Name, DOB, Age, Height and email address.
3. save
add some content
-Create another content type
(***)-Add a node reference field (referencing the "person" content type ) say Name reference (when the name is selected, the other fields should be auto filled)
-select an existing field from the "add existing field"
-add all the field to be autofilled. DOB.
save.
DO this for all the fields you want to be autofilled ( age, height, email address)
save.
Edit the node reference field you created in (***) above and scroll down to the ADDITIONAL BEHAVIORS section
-check the entity reference autofill option
-then check the fields you previously added
And thats it.
Test your content type by creating content.
Hope that's what you wanted.
Tech-256
I am trying to do a similar
I am trying to do a similar task.
I have the first content type that has a student ID and a student name field. It requires users to enter a student ID. When they enter the student ID, I want the name field to be autofilled based on the ID the user entered. I can not get this to work.
The name field that I want to auto fill is suppose to come from the second content type. This second content type creates content that has a student ID field and student name field. Right now, the content from this content type is created from a csv file. So I have about 5 students with ID's and names.
Do you know if it is possible, that when a user uses the first content type to find the student name associated with that ID, (autofill a student name) base on the student ID they provide?
Very possible
Hello fuzzbuzz, It is very possible to achieve your your goal. Actually this is why the autofill module was made.
First you have to download the autofill module and other module required.
I am assuming you have not created the content types.
1. Create the first content type say "student"
- add the required fields say ID, Name, sex etc
-save
2. Create a second content type say student reference
-scroll down and go to the section where it says "add existing field"
-select the student name and save (the "student name" field should be from the "student" content type)
Note: this field that will be autofilled
-Create a node reference field. This field should reference the content type you created before that is "student" select the field to be referenced. this will be the "ID"
-scroll down to additional behaviors section
---check the entity reference autofill option
---then check the "student name" field. It has to appear here
Save
Create content from the first "student" content type.
Test by creating content from the second "student reference" content type
It has to work
Tech-256
I'm sorry, but I do not
I'm sorry, but I do not follow.
Let me try to make it more clear. I am explaining exactly how I got it set up.
I have a content type named Attendance with a date, student id, and student name field.
The date field: is automatically filled with the current date.
The student ID: The student need to check into a library by scanning their ID number into this field. This will be the only user input.
The student Name field: The student name field IS WHAT I NEED TO BE AUTO FILLED. As soon as the student scans their ID into the student ID field, the student name field will need to be filled out automatically without any other student action.
Again, the Attendance content type is already created.
I have another content type called Student Data. Student data has fields that have a student ID and the student's name. This is the source for student records.
What I must do, is get the Attendance Content Type field, Student Name, to auto fill from the Student Data content type Student Name. It is the Student ID from the Attendance content type that will determine what name is auto filled.
Follow this procedure
Quick question, do you have these modules? Entity reference autofill module and Entity reference
If you have, then enable then and refresh your site
Note: Please follow the procedure below, slowly and read carefully
Go to the attendance content type, and delete the following fields.
- student id
- student name
Creating fields
1. scroll down and go to the section where it says "add existing field"
this is just below the "add new field" section
- in the "select an existing field" box, select student name. (this should be the same field in the "student data" content type.
Save
field name = Reference student ID, the machine name should be different from the student id in the "student data" content type.
Field type = entity reference
Form element = select list
Save
It will then take you to field setting page. Here you should do the following
-target type = node
-target bundles = check or tick the "student data"
save
This takes you to another page ( attendance form settings)
When you scroll down, you will see a section for "default value" here you are be able to see the the already created. Do not check any item.
Scroll to "additional behaviour" section
Check "Entity reference autofill" box and wait. After loading, you will see the field named "student name".
Select this field and then scroll down and save.
Go and create an attendance.
From the student id field, select the id
When you select the id, then the student name should automatically appear in the textbox.
Hope you get it now
Tech-256
I think I am miss
I think I am miss communicating what I need to do with this. I will have potentially hundreds of students using this form, so there is no way that I am going to require them to select their student ID from a drop down list of hundreds of ID's.
My users will not "SELECT THEIR ID" from the ID field. The USER WILL SCAN THEIR ID INTO THE 'STUDENT ID' FIELD BY PLACING THEIR ID UNDER A BARCODE READER.
When the barcode reader puts the scanned numbers into the 'STUDENT ID FIELD', this ID is what will determine WHAT NAME IS AUTOFILLED INTO THE "STUDENT NAME" field.
So, we are somewhat on the right track with you notes listed, HOWEVER, as mentioned above, there will be NO ID TO SELECT FROM. This ID will be either typed in or scanned in. IS THIS POSSIBLE to have the Student Reference ID be typed in (textbox) instead of selected (select list)?
I changed the 'select list'
I changed the 'select list' option on the entity reference field to 'autocomplete'. Now I can type in that field. The issue now is that the only way to get the name to autofill in the 'name' field of the attendance content type is to type the name (from a student content already created) into the 'student ID' field. I want to be able to type in the 'student id' to get the name to autofill.
Autocomplete may be slow
I dont know about scanning but there is this module Chosen. This will help you to see results as you are typing, hence reducing the type taken scrolling. You will also download the plugin and save in the libraries folder
chosen library This is faster than autocomplete option.
However, for the concern, if you had followed the instructions, then you will have no problem.
I think you mixed the fields involved. Check your fields, they should work correctly.
I have used the module several times and it gets to work.
Tech-256
Scanning is not the issue. I
Scanning is not the issue. I think your solution is not for my issue. I will battle this on my own for a bit and update the post if I work it out. If not I will just continue to build this as a web app outside of Drupal.
Thanks for your time and help and most of all your patience. The Drupal community is awesome.
UPDATE: The only way I was able to get this to work is when I import my student data from a CVS file, into a content type "Student Data", their "Student ID" number MUST be put into the "Title" field (the one that is required for all nodes). So, when I created the Attendance Log content type, I have the Student ID field of that content type reference the Student Data field which shows as "field_student_name avalailable in the bundle 'student data"'.
So, now when a student actually go to the Attendance Log (create content from Attendance Log content type), and scan their student ID, the Student Name is automatically populated.
So on that Student Data content type, I pretty much only created 1 field. That field is the "Student Name" field. The "Title" field is already there and it will basically be the Student ID number.
This is really sloppy to me and I hope that I am missing something here. But in the meantime I will go with this.
Good to know that you have
Good to know that you have managed somehow.
Goodluck
Tech-256
I need help
Hi, I've been trying my best to make this work but I might be missing something. I have already installed and updated the module.. I have created field from existing field like what you said. Then, i added field->reference autofill to student name.. but then its not populated automatically. Do you have new update to this module?
Thanks in advance :)
Can you expound on your issue please
Hello, can you tell me exactly what you want to do, then i can try to help where i can.
make sure you have downloaded the modules suggested in the comments above.
Best regards
Tech-256
Re-post
I have created the first content type is STUDENTINFO with field (studID, studName,etc) and second content type ENROLLMENT (EID, studID, studName).
I have already installed and enabled Entity reference autofill and Entity reference module. In the second content type ENROLLMENT, studID is added using the "add existing field", the field studname is added using the normal add new field but field type is entity reference and widget is autocomplete, in the field config target type is node,target bundles is STUDENTINFO. In "additional behaviour" section
"Entity reference autofill" box and "StudID" is checked.
When I load the ENROLLMENT form, studID is already populated with value from the first content type STUDENTINFO(studID), but when I choose value nothing happens in the studName field.
I want the studName to be automatically populated when I enter the studID.
Thanks and Mabuhay :)
Try to do this
Hello, a solution for you
Note: For this to work, Make sure that the studID is the title in the STUDENTINFO content type. or download a module called "Automatic Nodetitles" it helps to make a title from any fields in the content type
Then follow this
1. Delete the fields you have created in the ENROLLMENT content type ( studID and studName)
Now add an existing field ( studName NOT the studID) do not check the Entity reference autofill box in the "additional behaviour" section. Chose the target type node and bundles as STUDENTINFO. save
Now add a new field for student ID (not the same as the one in the STUDENTINFO content type . NOTE: do not add "an existing field"
The field type should be "entity reference" chose target type as node and bundles as STUDENTINFO.
Then scroll to the additional behaviors section and check the Entity reference autofill box. Upon selection, you will see the field below.
It will be in the form of" studName (field_studname): Available in bundle(s) studentinfo "
check the box for this field and save.
Test the solution, it should be able to work.
Let me hope this works for you
Best regards
Tech-256
Thanks a lot! I'm trying!
Thanks a lot! I'm trying!
No success, I have too much
No success, I have too much fields, a complicate situation and between references and field collection...Do you have time for a consultation?
Are you drupal expert?
We can meet
I am not drupal expert but we can set up a meet tomorrow before 3pm. Just tell me where i can find you.
Call me on this number. 0775621572
Tech-256
I'm Italian my friend! We can
I'm Italian my friend! We can chat by skype or whatsapp! My number is
+393474906600!
Thanks a lot!
I have created the first
I have created the first content type is STUDENTINFO with field (studID, studName,etc) and second content type ENROLLMENT (EID, studID, studName).
I have already installed and enabled Entity reference autofill and Entity reference module. In the second content type ENROLLMENT, studID is added using the "add existing field", the field studname is added using the normal add new field but field type is entity reference and widget is autocomplete, in the field config target type is node,target bundles is STUDENTINFO. In "additional behaviour" section
"Entity reference autofill" box and "StudID" is checked.
When I load the ENROLLMENT form, studID is already populated with value from the first content type STUDENTINFO(studID), but when I choose value nothing happens in the studName field.
I want the studName to be automatically populated when I enter the studID.
Thanks and Mabuhay :)
This seems straightforward,
This seems straightforward, hit me on skype (mugarurac)
https://www.youtube.com/watch
https://www.youtube.com/watch?v=1I09Dnhm4lQ
This video helped out!
Thanks, cavinm! Had a hard time figuring this one out, until I watched the vid, followed each step and got it working. The thing I kept missing out is the fact I should have an entity reference ID field, then indicate the entity bundle from here, where you get to select the fields that will auto-fill, of which both available (have been created) in both the source content type and destination content type (sort of what needs to be mapped in feeds.
An outstanding issue right now seems the when you are using addressfield (postal address). This is a note on the project page as a pending issue.
Watch the video! https://www.youtube.com/watch?v=1I09Dnhm4lQ
How to auto populate content type fields from an entityreference
I have the first content type that is vendors content type with a three field_groups i.e. name, location and contact details. My second content is Payment. It requires users to select a vendor name. When they select a vendor name, I want to autofill both location and contact details based on the vendor name the user entered. I can not get this to work.
Do you know if it is possible, that when a user uses the first content type to find the vendor locations and details associated with that vendor name, (autofill a vendor name and contacts) base on the vendor name they provide?
Hello, if you follow the
Hello, if you follow the solutions above, you will be able to forge your own solution. Just read carefully and get the right modules.
Goodluck
Tech-256
entity reference autofill
I posted a video on entity reference autofill, and he hasnt replied whether it worked for him or not, to master drupal, one of the key facets is reading, can't be a hard skill to grasp. People come to forums expecting answers, and hand holding, in the drupal world, it doesn't work like that.
autopopulate field in drupal8
Hi, i'm trying to do the same in drupal8 but there is no module in drupal8 as Entity reference autofill module. So can you please help me with this.
Me too
I've tried conditional fields, entity field token, field token value and still looking. Nothing works with Drupal 8!!! I am so sorry I made the move when D7 was working just fine for me and now with D8, page loads are MUCH SLOWER than with D7.
Folks, if it ain't broken, then don't fix it!