How do I set the value names of many_to_many inputs #814

Closed
jwaldrip opened this Issue Mar 1, 2012 · 3 comments

Projects

None yet

2 participants

@jwaldrip
jwaldrip commented Mar 1, 2012

I am trying to generate a list of contacts and I want the input to display a value of contact.first_name + " " + contact.last_name. When I use the following code I get the value of each contact as an object_id.

= f.input :contacts, as: :select_inline, label: false, input_html: { class: "inline chzn-select", :'data-placeholder' => "Choose a Contact" }
@jwaldrip
jwaldrip commented Mar 1, 2012

Note: select_inline is a custom input nearly identical to the orignal select input.

@justinfrench
Owner

Here's a quote from the documentation for SelectInput, which I assume you haven't read (but please help me clarify the docs if it simply didn't make sense to you):

The way on which Formtastic renders the value attribute and content of each <option> tag is customisable through the :member_label and :member_value options. When not provided, we fall back to a list of methods to try on each object such as :to_label, :name and :to_s, which are defined in the configurations collection_label_methods and collection_value_methods (see examples below).

@jwaldrip
jwaldrip commented Mar 1, 2012

My mistake. I was looking in the wiki and should have pulled the rdoc.

Sent from my iPhone

On Feb 29, 2012, at 9:24 PM, Justin Frenchreply@reply.github.com wrote:

Here's a quote from the documentation for SelectInput, which I assume you haven't read (but please help me clarify the docs if it simply didn't make sense to you):

The way on which Formtastic renders the value attribute and content of each <option> tag is customisable through the :member_label and :member_value options. When not provided, we fall back to a list of methods to try on each object such as :to_label, :name and :to_s, which are defined in the configurations collection_label_methods and collection_value_methods (see examples below).


Reply to this email directly or view it on GitHub:
#814 (comment)

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