I have a custom entity which represents a laboratory sample. This entity contains a custom multi-value field (analysis) with CARDINATITY_UNLIMITED for all the analyses that are performed on this sample. This works great for most analyses, for example, I can record the information on a sample (lot number, date sample was taken, etc) and measure its ph, and record the method ('ph') the date of analysis, and the result. I can also measure the temperature of this sample and record the method ('temp'), the date, and result.

However, some analysis methods return multiple results. A GC can return the concentrations of hundreds of compounds in one run. To represent this, I created a new entity called multi_analysis. This entity stores the method, the date, and a custom field. I also have an entity_reference to the sample that was analyzed. The custom field is CARDINATITY_UNLIMITED and lists the chemical name and the concentration for a specific multi_analysis.

I feel that, first off, I probably should move the entity reference to the sample entity with CARDINATITY_UNLIMITED, to make Widgeting simpler, despite the fact that this will create a new table.

If I did this, instead of using a entity_autocomple widget to find an existing multi_analysis entity in the sample addition form, is there a way to create a new multi_analysis entity within the sample entity admin page?

Alternatively, can I somehow make this multi-analysis a field and do the sample thing? Is it possible to have a field, which itself contains another field with CARDINATITY_UNLIMITED?

| improve this question | | | | |
  • There are some great modules, Inline Entity Form for the first question, Field Collection and Paragraphs for the second question. Did you investigate them? – 4k4 Jan 3 '17 at 16:29
  • Inline Entity Form looks like it's what I need, but it does not seem to be working. When I install the module and add a new entity reference field to an existing entity, and then go to the "Manage Form Display" tab, the select box next to the entity_reference field do not have a new option in them, just the standard Checkbox, Autocomplete (Select List), Select List, Autocomplete, and -Hidden-. I posted a bug report on the project page. – Kevin Nowaczyk Jan 4 '17 at 15:48
  • Did you add a controller EntityInlineEntityFormController to your custom entity type as mentioned in the README? – 4k4 Jan 4 '17 at 16:02
  • The D7 and D8 have the same README. I'm not sure if this is still needed for D8. – 4k4 Jan 4 '17 at 16:13
  • Couldn't get there yet. The part not working is step one of the "Getting Started" section. This suggestion is in the "Integrating with" section. – Kevin Nowaczyk Jan 4 '17 at 21:27

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.