I simply want to have a dropdown menu which will have all the rows of a table as its choices. How do I achieve that? Let's say I have a model "Student" and I want to have the "name" property to be displayed in the choices.
Thanks in advance.
You cannot "set a field to be a dropdown" in SQL Server. You can limit the acceptable values of this field in SQL Server. Then, in your UI language (C#, VB, ...) you can define a drop-down list which can be filled with values from this field. You can also do this in SQL Server Management Studio.
The default "Dropdown list" data-type will save the value you select - which would usually be the display text. Whereas the "Dropdown list with publishing keys" saves the PreValue id (from the database) instead of the text. You could use "umbraco. library.
The SELECT statement is used to select data from a database. The data returned is stored in a result table, called the result-set.
Use select, for example:
select(:model, :attribute, Student.all.collect {|p| [ p.name, p.id ] })
Here is some info on using collection selects...
http://www.fmhcc.com.au/ruby/rails/using-collection_select-in-rails/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With