I want to modify the user's drop-down in view of the collection. Rather than just seeing the "Products" field, I would like to like it as a "Wonder product, version" or something like that.
Can this be done with the 'options_from_collection_for_select' method? / Code>
Controller:
@external_tools = ExternalTool.all
/ former> model (via some different migration):
t.string: value t.string: validator t.string: example_answer t.boolean: Inaccurate, default => true t.boolean: is_file_upload ,: null => wrong, default => false add_reference: external_tool_questions ,: external_tool, index: true
I have tried:
I saw this document, but can not
I tried to guess now, but It is not working:
Code:
options_from_collection_for_select (@external_tools, "id", "product vendor")
(Also ... I can not understand how to select tags to work ... I'm also using a simpler form ... actually suppressing Not a problem, but just one side problem)
You can change your ExternalTool
like the following:
class ExternalTool def label "# {vendor} # {product} v # {version}" and end
When you set a variable in your controller:
< Pre> class SomeController & lt; ApplicationController def form_action @external_tools = ExternalTool.all end end
You can use it in your template:
options_from_collection_for_select (@external_tools, " Take a note that, in its third argument, accepts the name of the options_from_collection_for_select
name, "id", "label")
Here we are using label
in ExternalTool
.
Hope that helps! Good luck!
No comments:
Post a Comment