Let's say you have some nodes with fieldA, fieldB, and a radiobutton-widget. In each node, using the radiobuttons, you can chose which of the fields is supposed to be presented.

node 1: fieldA="Good", fieldB="Hello", radiobuttons: Not selected - Selected
node 2: fieldA="world", fieldB="bye", radiobuttons: Selected - Not selected

Is it possible to create a view with a table in which only one of the two field entries is shown depending on the radiobutton selection?

views-page:
fieldA/B
"Hello"
"world"

Comments

papricus’s picture

Assigned: papricus » Unassigned
dawehner’s picture

You could do this with custom theming. Justing using a different sql is afaik impossible.

dagmar’s picture

You can use Views CustomField

The PHP code for this extra field can be something like:

if ($data->field_show_property == 'a') {
  return $data->field_a;
}
else {
  return $data->field_b;
}

You have to exclude Field A, and Field B from view in order to see only one value.

If it works, please change status to fixed.

papricus’s picture

Status: Active » Fixed

Thanks

Status: Fixed » Closed (fixed)

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