I have nodes which contain taxonomy reference fields. I'm trying to get them to output as services raw format, so they'll be data objects in JSON and other output.

These fields contain (possibly) multiple values.

When trying to render as services raw format, no values are returned, at all. It shows the field as being empty, even though it isn't.

Comments

ideafarm’s picture

I am getting the same behavior

fiosca’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta2

Same for me! Does anybody have a solution to this bug?

dmizrahi’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev

Personnaly with the dev version, it shows me the tid of each term when using the row format.

[{"taxo":[{"tid":"11"},{"tid":"10"},{"tid":"12"}],"title":"nouveau contenu"}]

But with plain text format, each term is repeated :

[{"taxo":["Attente, Presentation, Theatre","Attente, Presentation, Theatre","Attente, Presentation, Theatre"],"title":"nouveau contenu"}]

I don't know if it is related.
I'm using Views-7.x-3.7 with Services-7.x-3.5

bessone’s picture

+1

pippopeppe’s picture

same here!

tanius’s picture

Issue summary: View changes

Short info for those who, like me, struggled to understand what "rendering as services raw" is: for some fields that you add to your view, there will be a "Formatter: Services raw" option in the field settings. For example for taxonomy terms, node body fields and other HTML input fields. It is not there for all fields, also not for all multi-value fields (the "User: Roles" field does not have it for example).

To render a field with multiple values via services_views into JSON or XML when "Formatter: Services raw" is not available for it, a workaround might be #678202-12: Views does not return taxonomy for Services. In the services_views documentation video however, they use a "Global: PHP" field from views_php for the purpose of rendering a tags multi-value field [source].

ben.kyriakou’s picture

StatusFileSize
new834 bytes

I've experienced a similar issue to #3 with multi-valued fields recently - instead of rendering as Services Raw I wanted to render as Plain Text or similar but have separate values. I tracked down the problem to the services_views resource - when rendering multi-value fields it does a pass for each value, but since it concatenates all the values it results in this duplication.

I've put in a quick patch that will convert output of the form;

{
  "foo": [
    "bar, baz",
    "bar, baz"
  ]
}

To something in the form;

{
  "foo": [
    "bar",
    "baz"
  ]
}

The patch creates a copy of the current row and removes all other values in the multi-value field apart from the one currently being processed, then passes it to the theming function as normal. Not the most elegant, but it works for my use-case.

ben.kyriakou’s picture

Status: Active » Needs review

Kicking off testing for the patch.

kylebrowning’s picture

Status: Needs review » Needs work

Needs a new re-roll!

pakmanlh’s picture

Status: Needs work » Closed (outdated)

I was able to show multiple term reference field values as soon as I removed all the style settings inside the field views configuration.
So I think that means this issue is gone.