Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using this wonderful module along with Paragraphs which relays on Entity API. Most of it works pretty well except for the answer validation, which only supports node entities, so I get this AJAX bug when user hits "Submit" into a quiz:
AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /system/ajax
StatusText: Service unavailable (with message)
ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7922 of /var/www/htdocs/includes/common.inc).
The module is doing calls to field_get_items() as follows:
$items = field_get_items('node', $form_state['values']['entity'], $form_state['values']['field_name']);
This is easy to fix by doing this instead:
$items = field_get_items($form_state['values']['entity']->entityType(), $form_state['values']['entity'], $form_state['values']['field_name']);
Comment | File | Size | Author |
---|---|---|---|
#11 | entity-support.patch | 4.5 KB | mishac |
Comments
Comment #2
Carsten Müller CreditAttribution: Carsten Müller as a volunteer commentedComment #4
Carsten Müller CreditAttribution: Carsten Müller as a volunteer commentedI checked this and added entity support fro all entity types but without using the Entity API module. It should now work for every entity type and also with the Entity API module.
I pushed this fix in the 7.x-1.x-dev branch, so it can be tested there. After this i will create a new release for it.
Comment #5
Carsten Müller CreditAttribution: Carsten Müller as a volunteer commentedpublished release 7.x-1.7 which includes this fix
Comment #6
justkristin CreditAttribution: justkristin commentedI have been trying to get it to work as a paragraph in D8... Is this problem with entities what is keeping my quiz paragraph from showing, perhaps? Or shall I keep banging away?
Comment #7
Carsten Müller CreditAttribution: Carsten Müller as a volunteer commentedHello justkristin,
this issue is by now just fixed for the Drupal 7 version. Currently I'm trying to fix the issues in Drupal 7 and then i will switch to the Drupal 8 version and will try to implement all the features there. I'm setting this issue to the Drupal 8 version now to be remembered.
Comment #8
justkristin CreditAttribution: justkristin commentedSir - I think I have paragraphs working, but the result is not shown via ajax, but rather by page reload. Is that related to this ticket? Or should I open another?
Thank you for all the work you do on this...
Comment #9
Carsten Müller CreditAttribution: Carsten Müller as a volunteer commentedHi,
i didn't test it with Paragraphs yet. I will do, when i have some time for this. But maybe this will take a while...
Comment #10
mishac CreditAttribution: mishac commentedI needed paragraph support so I made an initial stab at a patch to make the quiz work for any entity type. It also gets the entity ID from the FieldItemList object, rather than from the Route.
Comment #11
mishac CreditAttribution: mishac commentedWoops that patch includes some changes to the info.yml file that it shouldn't. this one should be better.
Comment #13
asrob