Permalink
Browse files

Some docs and changelog [ci skip]

  • Loading branch information...
1 parent 420d9be commit 7521f0393f6094cbba1b705f21683fd30331ca83 @carlosantoniodasilva carlosantoniodasilva committed Jan 26, 2012
Showing with 31 additions and 0 deletions.
  1. +5 −0 CHANGELOG.md
  2. +26 −0 lib/simple_form/action_view_extensions/builder.rb
View
@@ -22,6 +22,11 @@
* Add field_with_hint css class to the wrapper when the input has a hint, similar to field_with_errors ([@nashby](https://github.com/nashby))
* Add :grouped_select input type, mapping to Rails grouped_collection_select helper ([@semaperepelitsa](https://github.com/semaperepelitsa))
* Add automatic translation of options for collection inputs given a collection of symbols ([@klobuczek](https://github.com/klobuczek))
+ * Add `:boolean_style` config to change how check boxes and radios will be displayed.
+ Options are `:inline = input + label` (default) and `:nested = label > input`.
+ * Add possibility to give a block to `collection_radio` and `collection_check_boxes`,
+ to generate custom label and input structure. It is used internally with the :nested
+ option for `:boolean_style`, and is useful to allow some more customization if required.
### deprecation
* Deprecate the `translate` configuration in favor of `translate_labels`
@@ -22,6 +22,17 @@ module Builder
# <input id="user_options_false" name="user[options]" type="radio" value="false" />
# <label class="collection_radio" for="user_options_false">No</label>
#
+ # It is also possible to give a block that should generate the radio +
+ # label. To wrap the radio with the label, for instance:
+ #
+ # form_for @user do |f|
+ # f.collection_radio(
+ # :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
+ # ) do |label_for, text, value, html_options|
+ # f.label(label_for) { f.radio_button(attribute, value, html_options) + text }
+ # end
+ # end
+ #
# == Options
#
# Collection radio accepts some extra options:
@@ -37,6 +48,8 @@ module Builder
#
# * item_wrapper_tag => the tag to wrap each item in the collection.
#
+ # * a block => to generate the label + radio or any other component.
+ #
def collection_radio(attribute, collection, value_method, text_method, options={}, html_options={})
render_collection(
attribute, collection, value_method, text_method, options, html_options
@@ -69,6 +82,17 @@ def collection_radio(attribute, collection, value_method, text_method, options={
# <input id="user_options_false" name="user[options][]" type="checkbox" value="false" />
# <label class="collection_check_boxes" for="user_options_false">No</label>
#
+ # It is also possible to give a block that should generate the check box +
+ # label. To wrap the check box with the label, for instance:
+ #
+ # form_for @user do |f|
+ # f.collection_check_boxes(
+ # :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
+ # ) do |label_for, text, value, html_options|
+ # f.label(label_for) { f.check_box(attribute, html_options, value, '') + text }
+ # end
+ # end
+ #
# == Options
#
# Collection check box accepts some extra options:
@@ -85,6 +109,8 @@ def collection_radio(attribute, collection, value_method, text_method, options={
#
# * item_wrapper_tag => the tag to wrap each item in the collection.
#
+ # * a block => to generate the label + check box or any other component.
+ #
def collection_check_boxes(attribute, collection, value_method, text_method, options={}, html_options={})
render_collection(
attribute, collection, value_method, text_method, options, html_options

0 comments on commit 7521f03

Please sign in to comment.