I've installed the latest 8.x-5.0-beta6, but the same issue happens with beta5 and on dev too. I've added an "entity select" field/element to my webform and configured it to show taxonomy terms from a specified vocabulary. I chose to sort by term name ascending using the "default" reference method.
However, after saving the element, the drop-down continues to not be sorted by name. I think it might sorted by term weight.
I also tried configuring the entity select to show content of a particular type, sorting by title ascending, and again it didn't work. I'm not sure of the actual sort order used here, perhaps it's the creation date.
Comment | File | Size | Author |
---|---|---|---|
#6 | entity_select_sorting-2852676-6.patch | 1.84 KB | jrockowitz |
|
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer commented@stella I am seeing the below error in 'Recent Logs'
Can you please confirm that you are seeing the same error?
Comment #3
stella CreditAttribution: stella at Annertech for Glanbia commented@jrockowitz I only see that error after initially turning on the Sort as there appears to be no ajax enabled on that field (in fact I think I see code in the module that removes ajax from that select). This means when I change the "Sort by" from "-none-" to name or whatever, the "Sort direction" drop-down does not appear. Saving the form element and re-editing it causes it to appear.
FYI I'm happy to try and work on a patch towards this, just still trying to piece together where the problem actually is.
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedYes, I think there are some AJAX related issue with the UI for all entity reference webform elements.
Comment #5
stella CreditAttribution: stella at Annertech for Glanbia commentedYeah, I'm not too concerned with that as there's a workaround. However, I'm now also seeing similar errors when I try to edit the element and add a conditional rule to it - might be ajax related again, or might be something to do with entity select type, as I've had no problems editing other elements to add conditional rules. Putting them here, but can spin out to a separate issue if you think they're not related:
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI kind-of/sort-of knew the configuration form was a little broken when I implemented these entity reference elements but I wasn't sure how to fix it.
Hopefully, the attached patch finally fixes these little bugs.
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch. Please download and review the latest dev release.
Comment #10
ilclaudio CreditAttribution: ilclaudio commentedI have the same error "Notice: Undefined index: direction" on Drupal 8.3.4 (Webform 4.6.2) should I apply the same patch?
I've created a webform with a field "Entity Select" with:
- Type of item to reference: Content
- Reference method: Default
Using a view as Reference method, I don't have the error.
Notice: Undefined index: direction in Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->buildEntityQuery() (line 412 of core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php).
Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->buildEntityQuery(NULL, 'CONTAINS') (Line: 35)
Drupal\node\Plugin\EntityReferenceSelection\NodeSelection->buildEntityQuery(NULL, 'CONTAINS') (Line: 283)
Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->getReferenceableEntities() (Line: 49)
Drupal\webform\Element\WebformEntityTrait::setOptions(Array) (Line: 260)
Drupal\webform\Plugin\WebformElement\WebformEntitySelect->setOptions(Array) (Line: 30)
Drupal\webform\Plugin\WebformElement\WebformEntitySelect->prepare(Array, Object, NULL) (Line: 149)
Drupal\webform\WebformElementManager->invokeMethod('prepare', Array, Object) (Line: 1375)
Drupal\webform\WebformSubmissionForm->prepareElements(Array, Array, Object) (Line: 315)
Drupal\webform\WebformSubmissionForm->form(Array, Object) (Line: 115)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object) (Line: 252)
Drupal\webform\WebformSubmissionForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('webform_submission_revisione_auto_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('webform_submission_revisione_auto_form', Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'default') (Line: 869)
Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 82)
Drupal\webform\Controller\WebformController->addForm(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 38)
Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment #11
omdb CreditAttribution: omdb commentedThis patch doesn't work in the latest 8.x-5.0-beta15 version.
Notice: Undefined index: direction in Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->buildEntityQuery() (line 412 of core\lib\Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection.php).
Comment #12
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@see #2891637: Fix Entity Reference Trait