class ContactForm < Form text_field :subject, :max_length => 100 text_field :message email_field :sender boolean_field :cc_myself end f = ContactForm.new f.bound? #=> false data = { :subject => 'hello', :message => 'Hi there', :sender => 'foo@example.com', :cc_myself => true } f = ContactForm.new(data) f.bound? #=> true f.valid? #=> true f.render # or f.render_table # # # # f.render_p #

#

#

#

f.render_ul #
  • #
  • #
  • #
  • f = ContactForm.new({}) f.bound? #=> true f.valid? #=> false (invalid email) f.errors #=> {:sender => 'Enter a valid e-mail address.'}