Hi,

I'm trying to make users choose 3 different author name variants through a list select box using an entityreference (view). 

Why does the box show all 3 fields inline?:

In the View preview the<br> separator shows them fine like this:

I've seen that Show: Inline Fields is not changeable, and lists the dropdown items per row when a single entity like Content Title is chosen, but i'm trying to take 2 fields from Profile and 1 from Account for a simple select list. 

Any fixes, or other/better approaches?

 

 

Comments

It looks intentional, likely because it's an HTML list value which does not support multiple lines consistently. From entityreference_plugin_style.inc:

// Sanitize html, remove line breaks and extra whitespace.

Would it make sense to break these with other characters via the separator and field rewriting? e.g.

  • MyAcronym (My Full Name) - 1234567
  • MyAcronym -- My Full Name (1324567)

I'm not sure, could you kindly tutorialize this step just a little bit? 

I have no idea in terms of the dashes or brackets delimiting pattern, but i know that there can be only one separator type entered (?), but every combination turns out inline.

Upon reading the row style options again, is the whole entity reference view maybe against the whole multiple field listing idea (except for a singular field e.g. Content Title)?:

Note: In 'Entity Reference' displays, all fields will be displayed inline unless an explicit selection of inline fields is made here.

Just visually, here's the desired (devtools-simulated) result of how it should look like:

Other practices would not be so efficient i believe. This one would be in real-time on the other end (in case the users change their name, etc).

One example of how to do it would be to exclude all three fields from display and then enter a new "Custom text" field where you rewrite/format the values from the earlier fields in the field rewriting section. Then you wouldn't need the separator value at all, you'd be explicitly defining how to include them. The "Replacement Patterns" section nearby to this rewrite field would give you the actual tokens to use, but for example, something like this in the field rewriting text block:

[profile_acronym]: [profile_full_name] ([user_call_sign])

Thank you, 

I entered it like that in a Custom Text:

It's still inline, and the string is passing through like: 

Is there anything about these settings i need to change?:

No separator

 

All (3 fields') "Replacement patterns" sections are unchecked for now until further instructions.  

You may be able to just use the "Global: Custom Text" field as the search value, it's worth a test.

Does this look like a workable option, even though different from your original intention?

Sorry for the false steer @theflightrs, I may not have grasped your end goal correctly.

No problem, my site is quite a handful right now. Quite a lot of cross-referencing going on, yet to make it as user friendly as possible.

Reading through it sounds like:

  1. You want user to select out of three different options for displaying their "name" - Acronym, Full name, or User ID
  2. You have an entity reference display of a view but that is showing fields of a single entity
  3. Perhaps the view is a view of users with a contextual filter for the current user?

Entity reference fields are intended for selecting a single entity out of multiple entities rather than for selecting a field from an entity.

I'm not sure there is a simple way to do exactly what you are after, but there may be approaches that can deliver the same result, if my understanding is correct.

Thanks @yorkshirepudding, it looks like maybe I completely misunderstood the intention. The first time that's ever happened to me! ;)

@yorkshirepudding Yes,  it is filtered to the current user (not contextual):

So, in a nutshell! 

  • User writes a node.
  • Upon publishing, the selected list field value gets passed to the node.
  • A public view reads it out, where the author credit ("Written by:") is:

Or:

Or:

One approach I thought of is to have a field on their Profile that selects which format they want to use as their display format for their credentials when showing that they are the author.

This could then be used to select the right field, perhaps with Views Conditional or another approach to get this in a small block.

You could display this if they tick "show credentials"

@yorkshirepudding - Actually, this is plausible and could even be done in the node itself, but there are 2 concerns: 

  • Users have to go back to their profile each time to change it 
  • How does their selector get populated with their name variants (If it isn't literally "Acronym | Full Name | Code"?

It's basically a Grid View of short stories. The key feature of the site is that users should be able to select their credentials individually for each node, without affecting past content all at once.

 

 

So maybe if to be decided at the node level use Conditional Fields.  If you wanted to get into custom templates, this could be done in different ways but I've assumed you wanted to stick with no-code solutions.

I will tinker around with conditional fields. Thanks for the suggestions.

So far i only passed the author's Full Name into a single (hidden) Text field through a rule on node creation. 

Rules would be the very last option for that, especially for adding and removing list items. It's very manual and not as direct as some kind of conditional field. I'll report back if anything happens.