simple_form 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of simple_form might be problematic. Click here for more details.

@@ -8,7 +8,7 @@ SimpleForm aims to be as flexible as possible while helping you with powerful co
8
8
 
9
9
  Install the gem:
10
10
 
11
- sudo gem install simple_form --version=1.1
11
+ sudo gem install simple_form
12
12
 
13
13
  Run the generator:
14
14
 
@@ -26,9 +26,9 @@ SimpleForm was designed to be customized as you need to. Basically it's a stack
26
26
  To start using SimpleForm you just have to use the helper it provides:
27
27
 
28
28
  <% simple_form_for @user do |f| -%>
29
- <p><%= f.input :username %></p>
30
- <p><%= f.input :password %></p>
31
- <p><%= f.button :submit %></p>
29
+ <%= f.input :username %>
30
+ <%= f.input :password %>
31
+ <%= f.button :submit %>
32
32
  <% end -%>
33
33
 
34
34
  This will generate an entire form with labels for user name and password as well, and render errors by default when you render the form with invalid data (after submitting for example).
@@ -36,37 +36,37 @@ This will generate an entire form with labels for user name and password as well
36
36
  You can overwrite the default label by passing it to the input method, or even add a hint:
37
37
 
38
38
  <% simple_form_for @user do |f| -%>
39
- <p><%= f.input :username, :label => 'Your username please' %></p>
40
- <p><%= f.input :password, :hint => 'No special characters.' %></p>
41
- <p><%= f.button :submit %></p>
39
+ <%= f.input :username, :label => 'Your username please' %>
40
+ <%= f.input :password, :hint => 'No special characters.' %>
41
+ <%= f.button :submit %>
42
42
  <% end -%>
43
43
 
44
44
  You can also disable labels, hints or error or configure the html of any of them:
45
45
 
46
46
  <% simple_form_for @user do |f| -%>
47
- <p><%= f.input :username, :label_html => { :class => 'my_class' } %></p>
48
- <p><%= f.input :password, :hint => false, :error_html => { :id => "password_error"} %></p>
49
- <p><%= f.input :password_confirmation, :label => false %></p>
50
- <p><%= f.button :submit %></p>
47
+ <%= f.input :username, :label_html => { :class => 'my_class' } %>
48
+ <%= f.input :password, :hint => false, :error_html => { :id => "password_error"} %>
49
+ <%= f.input :password_confirmation, :label => false %>
50
+ <%= f.button :submit %>
51
51
  <% end -%>
52
52
 
53
53
  By default all inputs are required, which means an * is prepended to the label, but you can disable it in any input you want:
54
54
 
55
55
  <% simple_form_for @user do |f| -%>
56
- <p><%= f.input :name, :required => false %></p>
57
- <p><%= f.input :username %></p>
58
- <p><%= f.input :password %></p>
59
- <p><%= f.button :submit %></p>
56
+ <%= f.input :name, :required => false %>
57
+ <%= f.input :username %>
58
+ <%= f.input :password %>
59
+ <%= f.button :submit %>
60
60
  <% end -%>
61
61
 
62
62
  SimpleForm also lets you overwrite the default input type it creates:
63
63
 
64
64
  <% simple_form_for @user do |f| -%>
65
- <p><%= f.input :username %></p>
66
- <p><%= f.input :password %></p>
67
- <p><%= f.input :description, :as => :text %></p>
68
- <p><%= f.input :accepts, :as => :radio %></p>
69
- <p><%= f.button :submit %></p>
65
+ <%= f.input :username %>
66
+ <%= f.input :password %>
67
+ <%= f.input :description, :as => :text %>
68
+ <%= f.input :accepts, :as => :radio %>
69
+ <%= f.button :submit %>
70
70
  <% end -%>
71
71
 
72
72
  So instead of a checkbox for the :accepts attribute, you'll have a pair of radio buttons with yes/no labels and a text area instead of a text field for the description. You can also render boolean attributes using :as => :select to show a dropdown.
@@ -74,11 +74,11 @@ So instead of a checkbox for the :accepts attribute, you'll have a pair of radio
74
74
  SimpleForm also allows you using label, hint and error helpers it provides:
75
75
 
76
76
  <% simple_form_for @user do |f| -%>
77
- <p><%= f.label :username %></p>
78
- <p><%= f.text_field :username %></p>
79
- <p><%= f.error :username, :id => 'user_name_error' %></p>
80
- <p><%= f.hint 'No special characters, please!' %></p>
81
- <p><%= f.submit 'Save' %></p>
77
+ <%= f.label :username %>
78
+ <%= f.text_field :username %>
79
+ <%= f.error :username, :id => 'user_name_error' %>
80
+ <%= f.hint 'No special characters, please!' %>
81
+ <%= f.submit 'Save' %>
82
82
  <% end -%>
83
83
 
84
84
  Any extra option passed to label, hint or error will be rendered as html option.
@@ -88,9 +88,9 @@ Any extra option passed to label, hint or error will be rendered as html option.
88
88
  And what if you want to create a select containing the age from 18 to 60 in your form? You can do it overriding the :collection option:
89
89
 
90
90
  <% simple_form_for @user do |f| -%>
91
- <p><%= f.input :user %></p>
92
- <p><%= f.input :age, :collection => 18..60 %></p>
93
- <p><%= f.button :submit %></p>
91
+ <%= f.input :user %>
92
+ <%= f.input :age, :collection => 18..60 %>
93
+ <%= f.button :submit %>
94
94
  <% end -%>
95
95
 
96
96
  Collections can be arrays or ranges, and when a :collection is given the :select input will be rendered by default, so we don't need to pass the :as => :select option. Other types of collection are :radio and :check_boxes. Those are added by SimpleForm to Rails set of form helpers (read Extra Helpers session below for more information).
@@ -121,12 +121,12 @@ The first step is to configure a wrapper tag:
121
121
 
122
122
  SimpleForm.wrapper_tag = :p
123
123
 
124
- And now, you don't need to wrap your f.input calls with <p> anymore:
124
+ And now, you don't need to wrap your f.input calls with anymore:
125
125
 
126
126
  <% simple_form_for @user do |f| -%>
127
127
  <%= f.input :username %>
128
128
  <%= f.input :password %>
129
- <p><%= f.button :submit %></p>
129
+ <%= f.button :submit %>
130
130
  <% end -%>
131
131
 
132
132
  == Associations
@@ -149,10 +149,10 @@ To deal with associations, SimpleForm can generate select inputs or a series of
149
149
  Now we have the user form:
150
150
 
151
151
  <% simple_form_for @user do |f| -%>
152
- <p><%= f.input :name %></p>
153
- <p><%= f.association :company %></p>
154
- <p><%= f.association :roles %></p>
155
- <p><%= f.button :submit %></p>
152
+ <%= f.input :name %>
153
+ <%= f.association :company %>
154
+ <%= f.association :roles %>
155
+ <%= f.button :submit %>
156
156
  <% end -%>
157
157
 
158
158
  Simple enough right? This is going to render a :select input for choosing the :company, and another :select input with :multiple option for the :roles. You can of course change it, to use radios and check boxes as well:
@@ -178,8 +178,8 @@ The association helper just invokes input under the hood, so all options availab
178
178
  All web forms need buttons, right? SimpleForm wraps them in the DSL, acting like a proxy:
179
179
 
180
180
  <% simple_form_for @user do |f| -%>
181
- <p><%= f.input :name %></p>
182
- <p><%= f.button :submit %></p>
181
+ <%= f.input :name %>
182
+ <%= f.button :submit %>
183
183
  <% end -%>
184
184
 
185
185
  The above will simply call submit. You choose to use it or not, it's just a question of taste.
@@ -28,7 +28,7 @@ module SimpleForm
28
28
  end
29
29
 
30
30
  def label_text
31
- SimpleForm.label_text.call(raw_label_text, required_label_text)
31
+ SimpleForm.label_text.call(raw_label_text, required_label_text).html_safe
32
32
  end
33
33
 
34
34
  def label_target
@@ -39,7 +39,7 @@ module SimpleForm
39
39
  send(component)
40
40
  end
41
41
  content.compact!
42
- wrap(content.join).html_safe
42
+ wrap(content.join.html_safe)
43
43
  end
44
44
 
45
45
  protected
@@ -1,3 +1,3 @@
1
1
  module SimpleForm
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.1.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jos\xC3\xA9 Valim"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-07 00:00:00 +01:00
13
+ date: 2010-02-19 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies: []
16
16