Monday, 21 April 2014

SELECT_TAG DIFFERENT FORMS

  select tag 

syntax:

select_tag(name, option_tags = nil, options = {})

different forms of select_tag:

1, <%= select_tag :qual, options_for_select([["BE",1],["B.TECH",2],["ME",3],["M.TECH",4],["BSC",5]]), {:multiple=>true} %>

2,<%= select_tag :qual, options_for_select([["BE",1],["B.TECH",2],["ME",3],["M.TECH",4],["BSC",5]]), { include_blank: true }%>
 
3,
<%= select_tag :qual, options_for_select([["BE",1],["B.TECH",2],["ME",3],["M.TECH",4],["BSC",5]]), { :prompt => 'please select' }%>


 output: (1,2,3 outputs in sequence)

explanation: 

OPTIONS:

  1. :multiple - If set to true the selection will allow multiple choices.  
  2. :disabled - If set to true, the user will not be able to use this input.  
  3. :include_blank - If set to true, an empty option will be created. 
  4. :prompt - Create a prompt option with blank value and the text

Select In edit page: to get previous values

<%= f.select :genre, options_for_select([["Comedy",:Comedy],["Love",:Love],["Message",:Message],["Photography",:Photography],["Romantic",:Romantic],["Entertainment",:Entertainment],["Demo Oriented",:Demo],["Documentaries",:Documentaries],["Others",:Others]], @marketing.genre),{},{:class=>"multiselect",:multiple => true}%>

No comments:

Post a Comment