File: hello_controller.rb
class HelloController < ApplicationController
def showform
end
def show_formdata
@name = params[:name]
@prog_languages = params[:prog_languages] || []
@operating_systems = params[:operating_systems] || []
end
end
File: show_formdata.rhtml
Display Posted Form Data
Name: <%= @name %>
Programming Languages: <%= @prog_languages.join(", ") %>
Operating Systems: <%= @operating_systems.join(", ") %>
YAML Output from Debug:
<%= debug(params) %>
File: showform.rhtml
A Simple Form
<%= form_tag(:action => "show_formdata") %>
Text Field:
<%= text_field_tag("name","Aneesha") %>
Drop-down Selection Box:
<% languages = ["Ruby", "Java", "C#"].map do |lang|
""
end.to_s %>
<%= select_tag("prog_languages[]", languages, :multiple => "true") %>
Checkboxes:
<%= check_box_tag("operating_systems[]","Windows") %> Windows
<%= check_box_tag("operating_systems[]","Linux") %> Linux
<%= check_box_tag("operating_systems[]","Mac") %> Mac
<%= submit_tag("Submit Form") %>
<%= form_tag %>
getSetFormDataWithFormTag.zip( 91 k)