I have a text field that uses a select list of allowed values and all the values have a comma in them.
I had no problems with this setup until I tried to filter on that field. Whenever I saved the view, it would never save the items I selected for that field. When I checked out the database, the items were actually in there but it appears that commas are being used as separators on that database field so everything's getting screwed up since the data has commas as well.
I'm not sure if this is a bug or what. If we can't use commas, it should state that where you enter the allowed values list. It does say something about entering keys and labels though and if I used them I would have avoided this problem since I could have made the keys without commas. However, I can't really change the allowed values list now since doing so will affect all the content I already added.
Comments
Comment #1
merlinofchaos commentedI can't think of any fields that views uses commas as separators for inherently; what fields are you referring to?
Comment #2
bkark commentedLet me try to explain things a little better.
So I have a custom content type where one of the fields is text->select list. In the allowed values list of that field I have a list of cities, for example:
Denver, CO
New York, NY
San Francisco, CA
I didn't enter the cities in the format of "key|label" which I should have done since I would have avoided this problem.
Then I created a view and added that field as a filter. If I select any cities from the filter and save view, when the view reloads, the cities I selected are no longer selected...nothing is selected.
When I look in the view_filter database table I do see the cities that I just selected. The problem is that they are separated by commas. So when Views pulls these values out of the database, I assume it will break them up based on the commas. Of course this is a huge problem since the values already contain commas. So instead of having "New York, NY" as one value, it will have two, one for "New York" and another for " NY".
I hope this makes things a bit clearer.
Comment #3
merlinofchaos commentedSo when Views pulls these values out of the database, I assume it will break them up based on the commas.
I think this is going to be related to how the module that supplies the field implements the filter. Which means this is going to turn out to be a CCK issue. I assume by custom content type you're referring to a CCK field, at least. So I'm kicking this over to CCK.
Comment #4
yched commentedcck text fields with a set of allowed values expose this Views filter :
Problem is the selected options are stored in {view_filter}.value using a simple comma separator: you get "Denver, CO,New York, NY", and the values are mangled. Then the generated query looks like :
Not sure how and where this should be fixed ? My feeling is that a serialized array would fit best for this {view_filter}.value column...
Sending back to Views... Not sure Earl is willing to make such a change in D5 now, but I don't really know how we can workaround this on the CCK side.
Comment #5
merlinofchaos commentedThis will not be fixed in Views 1.