Skip to content

grosser/helpful_fields

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Many helpful field helpers for Rails(need ActionView)

  • prefilled form elements with values from params (even deep nesting like 'search[foo][bar][]')
  • check boxes/radio buttos with matching labels
  • selects directly filled with values

Install

sudo gem install helpful_fields

Or

rails plugin install git://github.com/grosser/helpful_fields.git

Usage

# text field filled from params
<%= params_text_field_tag 'search[category]' %>

# check box with label
# selected if params[:search][:user] is 1 or is an array that includes 1
<%= params_check_box_with_label 'search[with_user]', 1, 'Search with users' %>

# radio button with label, checked when in params
<%= params_radio_button_with_label 'search[type]', 'product', 'by Product' %>
<%= params_radio_button_with_label 'search[type]', 'shop', 'by Shop' %>

# select tag with options, preselected from params(or :value => xxx)
<%= params_select_options_tag :type, ['', 'none'] %>
<%= params_select_options_tag :type, [[0,'none'], [1, 'all']] %>
<%= params_select_options_tag :type, {'none' => 0, 'all' => 1} %>

# check box/radio with label for forms
<% f.check_box_with_label :is_admin, 'Can destroy stuff?' %>
<% f.radio_button_with_label :type, 'evil', 'No so nice' %>

TODO

  • support seperate options for label and input radio_button_with_label 'xxx', 'yyy', true, 'Label', :label => {:style => 'float:left'}, :input => {:class => 'evil'}

Author

Michael Grosser
michael@grosser.it
License: MIT
Build Status

About

Simple & Helpful Field Helpers for Rails e.g. check_box_with_label or prefilled fields from params

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages