Skip to content
Browse files

Merge pull request #46 from leucos/documentation/additions

Documentation/additions
  • Loading branch information...
2 parents f860d95 + 4f7651e commit 9ba170a1e040ff82983d0d5d01c525f78e878a6b @YorickPeterse YorickPeterse committed
Showing with 29 additions and 2 deletions.
  1. +29 −2 lib/ramaze/helper/blue_form.rb
View
31 lib/ramaze/helper/blue_form.rb
@@ -25,6 +25,11 @@ module Helper
# f.input_text 'Username', :username
# end
#
+ # The object comes handy when you want to do server-side form validation:
+ # if the form can not be validated, just send back the object with keys
+ # containing what the user has filled. The fields will be populated with
+ # these values, so the user doesn't have to retype everything.
+ #
# If you don't want to use an object you can simply set the first parameter
# to nil.
#
@@ -32,8 +37,20 @@ module Helper
#
# The form helper uses Gestalt, Ramaze's custom HTML builder that works
# somewhat like Erector. The output is very minimalistic, elements such as
- # legends and fieldsets have to be added manually. Each combination of a
- # label and input element will be wrapped in `<p>` tags.
+ # legends and fieldsets have to be added manually.
+ #
+ # If you need to add elements not covered by Form methods (e.g. `<div>`
+ # tags), you can access the form Gestalt instance with the g() method and
+ # generate your tags like this :
+ #
+ # form_for(@result, :method => :post) do |f|
+ # f.g.div(:class => "awesome") do
+ # ...
+ # end
+ # end
+ #
+ # Each combination of a label and input element will be wrapped in
+ # `<p>` tags.
#
# When using the form helper as a block in your templates it's important to
# remember that the result is returned and not displayed in the browser
@@ -49,6 +66,16 @@ module Helper
# f.input_text 'Username', :username
# end
#
+ # @example Adding custom elements inside a form
+ # form_for(@result, :method => :post) do |f|
+ # f.fieldset do
+ # f.g.div(:class => "control-group") do
+ # f.input_text 'Text label', :textname, { :placeholder => 'Chunky bacon!',
+ # :class => :bigsize }
+ # end
+ # end
+ # end
+ #
module BlueForm
##
# The form method generates the basic structure of the form. It should be

0 comments on commit 9ba170a

Please sign in to comment.
Something went wrong with that request. Please try again.