Guest User

Untitled

a guest
Apr 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #Problem is that cli_tag never spits the option with the proper value selected...
  2.  
  3. def cpp_select_tags
  4.  
  5. prg_tag = ""
  6. prj_tag = ""
  7.  
  8. client_id = nil
  9. project_id = nil
  10. program_id = nil
  11.  
  12. client_id = params[:cpp_cli][:client_id] if params[:cpp_cli] and params[:cpp_cli][:client_id]
  13. project_id = params[:cpp_prj][:project_id] if params[:cpp_prj] and params[:cpp_prj][:project_id]
  14. program_id = params[:cpp_prg][:program_id] if params[:cpp_prg] and params[:cpp_prg][:program_id]
  15.  
  16. options = {:include_blank => true}
  17. html_options = {:onchange => "document.forms[0].submit()"}
  18.  
  19. local_html_options = html_options; local_html_options.store(:selected,client_id)
  20. cli_tag = select("cpp_cli", "client_id", Client.find(:all).collect {|p| [ p.name, p.id ] }, options, local_html_options )
  21. if (client_id)
  22. prj_tag = select("cpp_prj", "project_id", Project.find(:all, :conditions => [ "client_id = ?", client_id ]).collect {|p| [ p.name, p.id ] }, options, html_options )
  23. if (project_id)
  24. prg_tag = select("cpp_prg", "program_id", Program.find(:all, :conditions => [ "project_id = ?", project_id ]).collect {|p| [ p.name, p.id ] }, options, html_options )
  25. end
  26. end
  27. auth_ht = "<input type=hidden name=authenticity_token value=#{form_authenticity_token}>\n"
  28. cli_tag << "\n<br/>" << prj_tag << "\n<br/>" << prg_tag << "\n<br/>" << auth_ht << "\n"
  29. end
Add Comment
Please, Sign In to add comment