Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[com_fields] list field with multi-select #16177

Closed
tonypartridge opened this issue May 22, 2017 · 19 comments
Closed

[com_fields] list field with multi-select #16177

tonypartridge opened this issue May 22, 2017 · 19 comments

Comments

@tonypartridge
Copy link
Contributor

tonypartridge commented May 22, 2017

When using the multi select field the raw_value is an array with multiple values else if its a singluar value it's a string.

IMO it should be an array at all times, whereas at the moment to output the raw value I now need to write a check for array do this if not do this.

It would be better practice to be an array at all times given it can handle multiple values.

@AlexRed
Copy link
Contributor

AlexRed commented May 22, 2017

@Bakual
Copy link
Contributor

Bakual commented May 22, 2017

Isn't that the behavior of all formfields? If a single value is stored, it's stored as a string and if you have multiple values it's stored as an array of strings. That's not unique to com_fields, you have that anywhere you use JForm. Or not?

@tonypartridge
Copy link
Contributor Author

@AlexRed I don't beleive so, since @PhilETaylor 's PR is for fixing the output of a single value to the value opposed to a comma separated value.

This is still right in non-numeric values. But I am on about the rawvalue output for multiple selects being either string or array.

I would suggest we adjust the list field @Bakual and set it to array if multi-select is enabled for the field in question. Thoughts?

@laoneo
Copy link
Member

laoneo commented May 22, 2017

That would be a BC break. I'm wondering me where do you need the check you are describing in your issue description.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16177.

@tonypartridge
Copy link
Contributor Author

tonypartridge commented May 22, 2017

@laoneo Would it though... since if you are using multiple you will need to be checking already if it's an array or not. It would only be a BC break in my eyes if we applied it to lists globally. And not just if it's a multi-select?

Simple, in this scenario we are using the List for departments and if the Person is in multiple departments we select multiple, but it many cases it's a single department.

So it outputs a string for the singles and an array for multiples even though the field is set as a multi-select, we use the raw value to build a filter. Whilst I can explode, clean, lower, replace space with _ to get the same result it's not ideal since we have the rawvalue field there we are using that.

@laoneo
Copy link
Member

laoneo commented May 22, 2017

If it comes now as string even tough multiselect is enabled and we are going to change that then it is a BC break in my eyes.
the problem is that you will need everywhere you are using the value an if condition to determine if it is a string or an array.

@tonypartridge
Copy link
Contributor Author

tonypartridge commented May 22, 2017 via email

@laoneo
Copy link
Member

laoneo commented May 22, 2017

This value is ment to be used on an output, for example the image list is returning a string with<img/> HTML code. According to your statement you would expect a list of image paths. That's why we have the raw value available.
If you need a kind of compiled values but not prepared for HTML output, then we need to think about a new attribute like compiledValue. Changing value can't be done imo.

@Bakual
Copy link
Contributor

Bakual commented May 22, 2017

If it comes now as string even tough multiselect is enabled and we are going to change that then it is a BC break in my eyes.

If the list is set up to allow multiple, the code already is able to deal with multiple values and thus an array. It's just the count of entries which would change.
As long as you only enforce the array when "multiple" is enabled, I think this should be fine to do.

I first understood that it should be always an array, also when multiple isn't selected. But that would be wrong.

@tonypartridge
Copy link
Contributor Author

tonypartridge commented May 22, 2017 via email

@laoneo
Copy link
Member

laoneo commented May 22, 2017

If the value attribute of a field changes within the J3 series from string to array, then it is a BC break IMO. Did I miss her something, but you want to change the value attribute of a field from string to array for multiselect lists, or? Means when I do then in my override echo $item->jcfields[2]->value, it will print out a comma separated list and after your suggestions then Array?

@Bakual
Copy link
Contributor

Bakual commented May 22, 2017

He talks about the rawvalue.

@tonypartridge
Copy link
Contributor Author

tonypartridge commented May 22, 2017 via email

@laoneo
Copy link
Member

laoneo commented May 23, 2017

Ah, I tough that I miss something here. Sorry for the noise. Changing the raw value to always be an array is fine IMO.

@brianteeman
Copy link
Contributor

@tonypartridge can you do a PR for this or shall I close it ?

@ghost
Copy link

ghost commented Sep 17, 2017

If this Issue get no Response, it will be closed at 22th October 2017.

@brianteeman
Copy link
Contributor

It is a valid issue that needs resolving by someone

@tonypartridge
Copy link
Contributor Author

I'm struggling for time at the moment, will see what I can do

@joomla-cms-bot joomla-cms-bot changed the title J3.7 com_fields list field with multi-select [com_fields] list field with multi-select Nov 7, 2017
@tonypartridge
Copy link
Contributor Author

We have a PR with discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants