When using Entity Reference View Widget, I always get the same error using exposed filters on a "Date" field.

When I setup my view, I create a "Entity View Reference Widget" display. In this display, I add a filter on a field called event date (field_date_evenement), which is a "Date" field (using the latest version of Date module). If I just add the filter, it all works well. Using an exposed filter in a normal display, like a block, it works fine too.
Using an entity reference view widget display, when I check this filter to be exposed, my view become unusable. I get this error reported just before the preview section and no preview can be generated :
SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)

Thus, in Views setting, I activated the SQL preview to see the query that was build. The section where my date filter is used changed from (with non-exposed filter) :
WHERE (( (node.status = '1') AND (node.type IN ('evenement')) AND (DATE_FORMAT(ADDTIME(field_data_field_date_evenement.field_date_evenement_value, SEC_TO_TIME(-18000)), '%Y-%m-%d') >= '2013-02-13') ))
to (with exposed filters) :

WHERE (( (node.status = '1') AND (node.type IN  ('evenement')) AND (DATE_FORMAT(ADDTIME(field_data_field_date_evenement.field_date_evenement_value, SEC_TO_TIME(-18000)), '%Y-%m-%d') >= '2013', '2', '13', '0', '0', '0') ))

The problem seems to be that the input received from the exposed filters does not get validated nor concatenated like the Date module normally does in Views.

At this point, if I try to edit a node with this Entity Reference Views Widget, the embedded view does not work at all anymore. All ajax actions (adding or removing an element, or filtering the view) end up in a javascript error and the throbber stays there in indefinitely.

I tried it both with the alpha and dev releases. Using the most recent version of all the aforementioned modules.

Comments

carolineboivin’s picture

The problem happens only using a date select, since the textfield (or the date popup widget, if installed) do not break the date in several parts. In my case, using a date popup or a textfield did the trick, although the bug might still be problematic if someone would require the use of a date select widget.

carolineboivin’s picture

Issue summary: View changes

Changed

for in original post for better readability
bojanz’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Issue summary: View changes
Status: Active » Fixed

This is most likely be fixed in the 2.x branch since it doesn't have the tricky exposed filter ajax overriding anymore.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.