Given you create a View that has a Content Pane display with an exposed sort and you've configured the "Allow settings" to enable "Use exposed widgets form as pane configuration" - when you add that pane and select a "Sort by", it will get correctly saved and used when displaying that pane. However, if you edit the settings on the pane again, the "Sort by" field will revert to the first value rather than the one that got saved.

This was discovered in Panopoly per this issue #2153291: The "Sort by" won't save in the "Content list" widget (switch from ctools patch to views patch).

I'll attach a patch to fix in a moment!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dsnopek’s picture

Status: Active » Needs review
FileSize
639 bytes

Attach is attached. Please let me know what you think!

dsnopek’s picture

Ack! New version that will actually check if there is a value before setting it. :-)

stella’s picture

Status: Needs review » Reviewed & tested by the community

Just applied the patch from #2 and it works perfectly. It's a fairly simple patch so marking as RTBC.

stella’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
982 bytes

Actually the same issue happens to the sort_order setting as well. Updated patch attached.

Status: Needs review » Needs work

The last submitted patch, 4: 2153811-4-views_pane_exposed_sort_by.patch, failed testing.

dsnopek’s picture

Actually, I didn't experience this problem with the sort order - it works fine for me for some reason. :-/

Also, here is an alternative patch that also fixes this problem, but it's a patch to Views rather than CTools:

https://drupal.org/comment/7993367#comment-7993367

I haven't had a ton of time to look into it, but I suspect that fixing this in Views is the right way to go...

dsnopek’s picture

Status: Needs work » Closed (duplicate)

I think the Views patch is actually more appropriate, since Views is the source! I tested this Views patch which is what we're now using in Panopoly: #2037469: Exposed Sort By and Sort Order view pane settings not retained

andrewmacpherson’s picture

Re-roll of the patch in comment #4.

Agreed, patching in views module is probably better, so leaving this marked as duplicate.
However we were already using the patch from comment #4, so I've included this re-roll, makes our module updates simpler.

This patch has no logic changes, just fixes the a/b addressing pre-amble.

Jorrit’s picture

Personally I prefer #8 over the views patch because it is only a problem when using ctools and views so fixing it in ctools seems more reasonable. Also, the patch proposed for views accesses $form_state['input'] in the form alter method which I consider a code smell, it is not a variable that should be accessed by form code in my opinion.

views_content_views_panes_content_type_edit_form() already sets #default_value on the exposed filter form elements, so setting this on the exposed order/sort seems to be not too inappropriate.