Skip to content

Instantly share code, notes, and snippets.

@alexch
Created June 17, 2011 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexch/1031839 to your computer and use it in GitHub Desktop.
Save alexch/1031839 to your computer and use it in GitHub Desktop.
class HowManyLicks < QuestionForm
def content
overview do
title_element "How many licks?"
text_element "Please tell us how many licks it takes to get to the center of these things."
formattedcontent do
rawtext "<![CDATA[\n"
p do
a :href => "http://tootsiepop.com/instructions.html" do
b "Click here to read the instructions!"
end
end
rawtext "\n]]>"
end
end
@items.each do |item|
question do
questionidentifier item.id
displayname item.name
isrequired true
questioncontent do
text_element do
text item.name
text "?"
end
end
answerspecification do
selectionanswer do
minselectioncount 0
stylesuggestion "radiobutton"
selections do
selection do
selectionidentifier "1"
text_element "One"
end
selection do
selectionidentifier "2"
text_element "Two"
end
selection do
selectionidentifier "3"
text_element "Three"
end
end
end
end
end
end
question do
questionidentifier "comments"
questioncontent do
text_element "Do you have any comments?"
end
answerspecification do
freetextanswer
end
end
end
end
# assuming your own domain object called "Item"
HowManyLicks.new(:items => [Item.new(99, "Tootsie Pop")]).to_html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment