Skip to content
Newer
Older
100644 643 lines (482 sloc) 26.3 KB
420b4ce @justinfrench sick of updating the README with every version bump :)
authored Apr 22, 2009
1 h1. Formtastic
dcf8beb Initial Commit
Justin French authored Apr 7, 2008
2
3 Formtastic is a Rails FormBuilder DSL (with some other goodies) to make it far easier to create beautiful, semantically rich, syntactically awesome, readily stylable and wonderfully accessible HTML forms in your Rails applications.
4
cd0a1ba @justinfrench pledgie image URL is a redirect, so here's the real URL
authored Nov 17, 2010
5 <a href='http://www.pledgie.com/campaigns/2178'><img alt='Click here to lend your support to: formtastic and make a donation at www.pledgie.com !' src='http://pledgie.com/campaigns/2178.png?skin_name=chrome' border='0' /></a>
1bbe8ea @justinfrench add the pledgie badge back in, GH don't show them any more?
authored Oct 8, 2010
6
dc5857b @justinfrench moved compatibility note in README further up
authored Jan 13, 2011
7
8 h2. Compatibility
9
a69e7b8 @justinfrench note that 2.1.x is required for Rails 3.2 in README, ref #785
authored Jan 30, 2012
10 * Formtastic 2.1.x is Rails 3.x compatible
11 * Formtastic 2.0.x is Rails 3.0.x and 3.1.x compatible only
22a9af1 @justinfrench prep README for 2.0
authored Sep 2, 2011
12 * Formtastic 1.x is compatible with both Rails 2 and 3, and is being maintained for bug fixes in the the "1.2-stable branch":https://github.com/justinfrench/formtastic/tree/1.2-stable. View the README in that branch for installation instructions, etc.
dc5857b @justinfrench moved compatibility note in README further up
authored Jan 12, 2011
13 * Formtastic, much like Rails, is very ActiveRecord-centric. Many are successfully using other ActiveModel-like ORMs and objects (DataMapper, MongoMapper, Mongoid, Authlogic, Devise...) but we're not guaranteeing full compatibility at this stage. Patches are welcome!
14
15
09d957d textilized the README so that it looks pretty pretty on GitHub
Justin French authored Apr 29, 2008
16 h2. The Story
dcf8beb Initial Commit
Justin French authored Apr 7, 2008
17
2d4a72b @justinfrench big update to the README
authored Feb 16, 2009
18 One day, I finally had enough, so I opened up my text editor, and wrote a DSL for how I'd like to author forms:
dcf8beb Initial Commit
Justin French authored Apr 7, 2008
19
09d957d textilized the README so that it looks pretty pretty on GitHub
Justin French authored Apr 29, 2008
20 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 28, 2011
21 <%= semantic_form_for @article do |f| %>
22
23 <%= f.inputs :name => "Basic" do %>
24 <%= f.input :title %>
25 <%= f.input :body %>
26 <%= f.input :section %>
27 <%= f.input :publication_state, :as => :radio %>
28 <%= f.input :category %>
29 <%= f.input :allow_comments, :label => "Allow commenting on this article" %>
353618e @markmansour Extending Formtastic can be done by overriding the semantic_form_buil…
markmansour authored Jan 13, 2009
30 <% end %>
31
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
32 <%= f.inputs :name => "Advanced" do %>
33 <%= f.input :keywords, :required => false, :hint => "Example: ruby, rails, forms" %>
34 <%= f.input :extract, :required => false %>
35 <%= f.input :description, :required => false %>
36 <%= f.input :url_title, :required => false %>
7e3874a @justinfrench trying to fix README formatting of <'s at the start of lines
authored Aug 13, 2008
37 <% end %>
38
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
39 <%= f.inputs :name => "Author", :for => :author do |author_form| %>
05ae54d @josevalim Fixed nested attributes example in README
josevalim authored Mar 22, 2009
40 <%= author_form.input :first_name %>
41 <%= author_form.input :last_name %>
9997ce6 @josevalim Added more information about inputs :for in README.
josevalim authored Mar 7, 2009
42 <% end %>
43
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
44 <%= f.actions do %>
45 <%= f.action :submit, :as => :button %>
46 <%= f.action :cancel, :as => :link %>
7e3874a @justinfrench trying to fix README formatting of <'s at the start of lines
authored Aug 14, 2008
47 <% end %>
09d957d textilized the README so that it looks pretty pretty on GitHub
Justin French authored Apr 29, 2008
48
dcf8beb Initial Commit
Justin French authored Apr 7, 2008
49 <% end %>
09d957d textilized the README so that it looks pretty pretty on GitHub
Justin French authored Apr 29, 2008
50 </pre>
51
6734cfd @justinfrench sme typos and cleanups in the readme
authored Jul 21, 2008
52 I also wrote the accompanying HTML output I expected, favoring something very similar to the fieldsets, lists and other semantic elements Aaron Gustafson presented in "Learning to Love Forms":http://www.slideshare.net/AaronGustafson/learning-to-love-forms-web-directions-south-07, hacking together enough Ruby to prove it could be done.
dcf8beb Initial Commit
Justin French authored Apr 7, 2008
53
54
bdbe30b @justinfrench a few README clean-ups for 2.0
authored Sep 23, 2011
55 h2. It's awesome because...
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
56
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
57 * It can handle @belongs_to@ associations (like Post belongs_to :author), rendering a select or set of radio inputs with choices from the parent model.
58 * It can handle @has_many@ and @has_and_belongs_to_many@ associations (like: Post has_many :tags), rendering a multi-select with choices from the child models.
59 * It's Rails 3 compatible (including nested forms).
60 * It has internationalization (I18n)!
61 * It's _really_ quick to get started with a basic form in place (4 lines), then go back to add in more detail if you need it.
62 * There's heaps of elements, id and class attributes for you to hook in your CSS and JS.
63 * It handles real world stuff like inline hints, inline error messages & help text.
64 * It doesn't hijack or change any of the standard Rails form inputs, so you can still use them as expected (even mix and match).
65 * It's got absolutely awesome spec coverage.
66 * There's a bunch of people using and working on it (it's not just one developer building half a solution).
67 * It has growing HTML5 support (new inputs like email/phone/search, new attributes like required/min/max/step/placeholder)
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
68
69
15e0bd9 updated the README a little to match last night's slides
Justin French authored May 30, 2008
70 h2. Opinions
71
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
72 * It should be easier to do things the right way than the wrong way.
73 * Sometimes _more mark-up_ is better.
74 * Elements and attribute hooks are _gold_ for stylesheet authors.
75 * Make the common things we do easy, yet ensure uncommon things are still possible.
15e0bd9 updated the README a little to match last night's slides
Justin French authored May 29, 2008
76
dcf8beb Initial Commit
Justin French authored Apr 7, 2008
77
3dd6455 @justinfrench Link to RDoc URL in README
authored Jul 3, 2009
78 h2. Documentation
79
80 RDoc documentation _should_ be automatically generated after each commit and made available on the "rdoc.info website":http://rdoc.info/projects/justinfrench/formtastic.
81
82
e3f04f6 @justinfrench README installation instructions simlified and clarified to specific …
authored Sep 13, 2010
83 h2. Installation
c89e985 @justinfrench updating README with gem/plugin installation instructions
authored Mar 8, 2009
84
ebe4e51 @justinfrench updated the README to reflect the new gem versions and other compatib…
authored Sep 8, 2010
85 Simply add Formtastic to your Gemfile and bundle it up:
557f929 @justinfrench updated README to reflect new 1.1.0.beta gem, etc
authored Aug 28, 2010
86
87 <pre>
22a9af1 @justinfrench prep README for 2.0
authored Sep 1, 2011
88 gem 'formtastic'
557f929 @justinfrench updated README to reflect new 1.1.0.beta gem, etc
authored Aug 28, 2010
89 </pre>
90
22a9af1 @justinfrench prep README for 2.0
authored Sep 1, 2011
91 Run the installation generator:
c89e985 @justinfrench updating README with gem/plugin installation instructions
authored Mar 8, 2009
92
93 <pre>
e3f04f6 @justinfrench README installation instructions simlified and clarified to specific …
authored Sep 13, 2010
94 $ rails generate formtastic:install
c89e985 @justinfrench updating README with gem/plugin installation instructions
authored Mar 8, 2009
95 </pre>
96
ebe4e51 @justinfrench updated the README to reflect the new gem versions and other compatib…
authored Sep 8, 2010
97
98 h2. Stylesheets
c89e985 @justinfrench updating README with gem/plugin installation instructions
authored Mar 8, 2009
99
28754a2 @justinfrench updated README for asset pipeline with ie6 & 7 css
authored Jun 3, 2011
100 A proof-of-concept set of stylesheets are provided which you can include in your layout. Customization is best achieved by overriding these styles in an additional stylesheet.
4f4b069 @justinfrench Rails 3.1 Asset Pipeline compatibility (Fixes #563)
authored May 31, 2011
101
102 h3. Stylesheet usage in Rails < 3.1:
103
104 <pre>
105 $ rails generate formtastic:install
106 </pre>
107
108 <pre>
109 # app/views/layouts/application.html.erb
110 <%= stylesheet_link_tag 'formtastic', 'my_formtastic_changes' %>
28754a2 @justinfrench updated README for asset pipeline with ie6 & 7 css
authored Jun 2, 2011
111 <!--[if IE 6]><%= stylesheet_link_tag 'formtastic_ie6' %><![endif]-->
112 <!--[if IE 7]><%= stylesheet_link_tag 'formtastic_ie7' %><![endif]-->
4f4b069 @justinfrench Rails 3.1 Asset Pipeline compatibility (Fixes #563)
authored May 30, 2011
113 </pre>
114
115 h3. Stylesheet usage in Rails >= 3.1:
116
28754a2 @justinfrench updated README for asset pipeline with ie6 & 7 css
authored Jun 2, 2011
117 Rails 3.1 introduces an asset pipeline that allows plugins like Formtastic to serve their own Stylesheets, Javascripts, etc without having to run generators that copy them accross to the host application. Formtastic makes three stylesheets available as an Engine, you just need to require them in your global stylesheets.
c89e985 @justinfrench updating README with gem/plugin installation instructions
authored Mar 8, 2009
118
5c1ce48 @justinfrench moved the stylesheets stuff up with installation
authored Oct 21, 2009
119 <pre>
4f4b069 @justinfrench Rails 3.1 Asset Pipeline compatibility (Fixes #563)
authored May 30, 2011
120 # app/assets/stylesheets/application.css
121 *= require formtastic
28754a2 @justinfrench updated README for asset pipeline with ie6 & 7 css
authored Jun 2, 2011
122 *= require my_formtastic_changes
123
124 # app/assets/stylesheets/ie6.css
125 *= require formtastic_ie6
126
127 # app/assets/stylesheets/ie7.css
128 *= require formtastic_ie7
5c1ce48 @justinfrench moved the stylesheets stuff up with installation
authored Oct 21, 2009
129 </pre>
2526d2c @justinfrench Going back to generators instead of Rake tasks for copying stylesheet…
authored Oct 11, 2009
130
28754a2 @justinfrench updated README for asset pipeline with ie6 & 7 css
authored Jun 2, 2011
131 <pre>
132 # app/views/layouts/application.html.erb
133 <%= stylesheet_link_tag 'application' %>
134 <!--[if IE 6]><%= stylesheet_link_tag 'ie6' %><![endif]-->
135 <!--[if IE 7]><%= stylesheet_link_tag 'ie7' %><![endif]-->
136 </pre>
137
138
4036e74 @justinfrench pruning and cleaning up the README, it's been a while
authored Jul 21, 2010
139
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
140 h2. Usage
141
142 Forms are really boring to code... you want to get onto the good stuff as fast as possible.
143
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
144 This renders a set of inputs (one for _most_ columns in the database table, and one for each ActiveRecord @belongs_to@-association), followed by default action buttons (an input submit button):
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
145
146 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
147 <%= semantic_form_for @user do |f| %>
148 <%= f.inputs %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
149 <%= f.actions %>
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
150 <% end %>
151 </pre>
152
bdbe30b @justinfrench a few README clean-ups for 2.0
authored Sep 23, 2011
153 This is a great way to get something up fast, but like scaffolding, it's *not recommended for production*. Don't be so lazy!
5018ed0 @justinfrench clarified the differences in Rails 2 and 3 ERB blocks, and some other…
authored Nov 5, 2010
154
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
155 To specify the order of the fields, skip some of the fields or even add in fields that Formtastic couldn't infer. You can pass in a list of field names to @inputs@ and list of action names to @actions@:
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
156
157 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
158 <%= semantic_form_for @user do |f| %>
159 <%= f.inputs :title, :body, :section, :categories, :created_at %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
160 <%= f.actions :submit, :cancel %>
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
161 <% end %>
162 </pre>
163
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
164 You probably want control over the input type Formtastic uses for each field. You can expand the @inputs@ and @actions@ to block helper format and use the @:as@ option to specify an exact input type:
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
165
166 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
167 <%= semantic_form_for @post do |f| %>
168 <%= f.inputs do %>
169 <%= f.input :title %>
170 <%= f.input :body %>
171 <%= f.input :section, :as => :radio %>
172 <%= f.input :categories %>
173 <%= f.input :created_at, :as => :string %>
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
174 <% end %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
175 <%= f.actions do %>
176 <%= f.action :submit, :as => :button %>
177 <%= f.action :cancel, :as => :link %>
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
178 <% end %>
179 <% end %>
180 </pre>
181
a45853c @justinfrench small README typo
authored Apr 19, 2009
182 If you want to customize the label text, or render some hint text below the field, specify which fields are required/optional, or break the form into two fieldsets, the DSL is pretty comprehensive:
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
183
184 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
185 <%= semantic_form_for @post do |f| %>
186 <%= f.inputs "Basic", :id => "basic" do %>
187 <%= f.input :title %>
188 <%= f.input :body %>
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
189 <% end %>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
190 <%= f.inputs :name => "Advanced Options", :id => "advanced" do %>
191 <%= f.input :slug, :label => "URL Title", :hint => "Created automatically if left blank", :required => false %>
192 <%= f.input :section, :as => :radio %>
193 <%= f.input :user, :label => "Author", :member_label => :full_name %>
194 <%= f.input :categories, :required => false %>
195 <%= f.input :created_at, :as => :string, :label => "Publication Date", :required => false %>
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
196 <% end %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
197 <%= f.actions do %>
390ced4 @haines Minor formatting/typo fixes
haines authored Jan 16, 2012
198 <%= f.action :submit %>
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
199 <% end %>
200 <% end %>
201 </pre>
202
4033f27 @nathanl Small addition to documentation
nathanl authored Nov 11, 2010
203 You can create forms for nested resources:
204
205 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
206 <%= semantic_form_for [@author, @post] do |f| %>
4033f27 @nathanl Small addition to documentation
nathanl authored Nov 11, 2010
207 </pre>
208
bcd3ba9 @justinfrench some README updates
authored Oct 26, 2010
209 Nested forms are also supported (don't forget your models need to be setup correctly with @accepts_nested_attributes_for@). You can do it in the Rails way:
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
210
211 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
212 <%= semantic_form_for @post do |f| %>
213 <%= f.inputs :title, :body, :created_at %>
214 <%= f.semantic_fields_for :author do |author| %>
1fcc068 @grimen An effort to make the README somewhat more readable.
grimen authored Oct 25, 2009
215 <%= author.inputs :first_name, :last_name, :name => "Author" %>
41a6754 @josevalim Another README fix.
josevalim authored Mar 24, 2009
216 <% end %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
217 <%= f.actions %>
9997ce6 @josevalim Added more information about inputs :for in README.
josevalim authored Mar 7, 2009
218 <% end %>
219 </pre>
220
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
221 Or the Formtastic way with the @:for@ option:
9997ce6 @josevalim Added more information about inputs :for in README.
josevalim authored Mar 7, 2009
222
223 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
224 <%= semantic_form_for @post do |f| %>
225 <%= f.inputs :title, :body, :created_at %>
226 <%= f.inputs :first_name, :last_name, :for => :author, :name => "Author" %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
227 <%= f.actions %>
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
228 <% end %>
229 </pre>
230
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
231 When working in has many association, you can even supply @"%i"@ in your fieldset name; they will be properly interpolated with the child index. For example:
d5e3b0a @josevalim Added nested child nindex support.
josevalim authored Mar 24, 2009
232
233 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
234 <%= semantic_form_for @post do |f| %>
235 <%= f.inputs %>
236 <%= f.inputs :name => 'Category #%i', :for => :categories %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
237 <%= f.actions %>
d5e3b0a @josevalim Added nested child nindex support.
josevalim authored Mar 24, 2009
238 <% end %>
239 </pre>
240
8b1f016 @mhuggins Pass current label as arguments to inputs block for nested inputs
mhuggins authored Feb 12, 2012
241 Alternatively, the current index can be accessed via the `inputs` block's arguments for use anywhere:
242
243 <pre>
244 <%= semantic_form_for @post do |f| %>
245 <%= f.inputs :for => :categories do |category, i| %>
246 <% if i <= 2 %>
247 <%= f.inputs :name => "Category ##{i}" %>
248 <% else %>
249 <%= f.inputs :name => "Category ##{i} (optional)" %>
250 <% end %>
251 <% end %>
252 <%= f.actions %>
253 <% end %>
254 </pre>
255
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
256 If you have more than one form on the same page, it may lead to HTML invalidation because of the way HTML element id attributes are assigned. You can provide a namespace for your form to ensure uniqueness of id attributes on form elements. The namespace attribute will be prefixed with underscore on the generate HTML id. For example:
d174db0 @asanghi change id_prefix to namespace; added documentation in README
asanghi authored Oct 24, 2010
257
258 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
259 <%= semantic_form_for(@post, :namespace => 'cat_form') do |f| %>
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 28, 2011
260 <%= f.inputs do %>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
261 <%= f.input :title %> # id="cat_form_post_title"
262 <%= f.input :body %> # id="cat_form_post_body"
263 <%= f.input :created_at %> # id="cat_form_post_created_at"
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 27, 2011
264 <% end %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
265 <%= f.actions %>
d174db0 @asanghi change id_prefix to namespace; added documentation in README
asanghi authored Oct 24, 2010
266 <% end %>
267 </pre>
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
268
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
269 Customize HTML attributes for any input using the @:input_html@ option. Typically this is used to disable the input, change the size of a text field, change the rows in a textarea, or even to add a special class to an input to attach special behavior like "autogrow":http://plugins.jquery.com/project/autogrowtextarea textareas:
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
270
271 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
272 <%= semantic_form_for @post do |f| %>
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 27, 2011
273 <%= f.inputs do %>
c36692c @justinfrench cols => size in README, fixes #753
authored Dec 12, 2011
274 <%= f.input :title, :input_html => { :size => 10 } %>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
275 <%= f.input :body, :input_html => { :class => 'autogrow', :rows => 10, :cols => 20, :maxlength => 10 } %>
276 <%= f.input :created_at, :input_html => { :disabled => true } %>
c7b9849 @ZachBeta Added a little sample of :input_html => { :readonly => true } which I…
ZachBeta authored Jan 10, 2012
277 <%= f.input :updated_at, :input_html => { :readonly => true } %>
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 27, 2011
278 <% end %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
279 <%= f.actions %>
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
280 <% end %>
281 </pre>
282
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
283 The same can be done for actions with the @:button_html@ option:
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
284
285 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
286 <%= semantic_form_for @post do |f| %>
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
287 ...
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
288 <%= f.actions do %>
289 <%= f.action :submit, :button_html => { :class => "primary", :disable_with => 'Wait...' } %>
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
290 <% end %>
291 <% end %>
292 </pre>
293
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
294 Customize the HTML attributes for the @<li>@ wrapper around every input with the @:wrapper_html@ option hash. There's one special key in the hash: (@:class@), which will actually _append_ your string of classes to the existing classes provided by Formtastic (like @"required string error"@).
1fcc068 @grimen An effort to make the README somewhat more readable.
grimen authored Oct 25, 2009
295
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
296 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
297 <%= semantic_form_for @post do |f| %>
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 27, 2011
298 <%= f.inputs do %>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
299 <%= f.input :title, :wrapper_html => { :class => "important" } %>
300 <%= f.input :body %>
301 <%= f.input :description, :wrapper_html => { :style => "display:none;" } %>
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 27, 2011
302 <% end %>
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
303 ...
304 <% end %>
305 </pre>
306
cb0f12e @brentvatne Fix README to reference the correct filepath (config/initializers) fo…
brentvatne authored Dec 13, 2011
307 Customize the default class used for hints on each attribute or globally in the @config/initializers/formtastic.rb@ file. Similarly, you can customize the error classes on an attribute level or globally.
d174db0 @asanghi change id_prefix to namespace; added documentation in README
asanghi authored Oct 24, 2010
308
309 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
310 <%= semantic_form_for @post do |f| %>
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 27, 2011
311 <%= f.inputs do %>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
312 <%= f.input :title, :hint_class => 'custom-html-class', :error_class => 'custom-error-class' %>
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 27, 2011
313 <% end %>
d174db0 @asanghi change id_prefix to namespace; added documentation in README
asanghi authored Oct 24, 2010
314 <% end %>
315 </pre>
316
a92cf7c @justinfrench added documentation for :collection option, resolves #181
authored Mar 13, 2010
317 Many inputs provide a collection of options to choose from (like @:select@, @:radio@, @:check_boxes@, @:boolean@). In many cases, Formtastic can find choices through the model associations, but if you want to use your own set of choices, the @:collection@ option is what you want. You can pass in an Array of objects, an array of Strings, a Hash... Throw almost anything at it! Examples:
318
319 <pre>
f6d792f @denispeplin Replace deprecated "find(:all)" with "all" method
denispeplin authored Feb 24, 2012
320 f.input :authors, :as => :check_boxes, :collection => User.order("last_name ASC").all
a92cf7c @justinfrench added documentation for :collection option, resolves #181
authored Mar 13, 2010
321 f.input :authors, :as => :check_boxes, :collection => current_user.company.users.active
322 f.input :authors, :as => :check_boxes, :collection => [@justin, @kate]
323 f.input :authors, :as => :check_boxes, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
f6d792f @denispeplin Replace deprecated "find(:all)" with "all" method
denispeplin authored Feb 24, 2012
324 f.input :author, :as => :select, :collection => Author.all
a92cf7c @justinfrench added documentation for :collection option, resolves #181
authored Mar 13, 2010
325 f.input :author, :as => :select, :collection => { @justin.name => @justin.id, @kate.name => @kate.id }
326 f.input :author, :as => :select, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
f6d792f @denispeplin Replace deprecated "find(:all)" with "all" method
denispeplin authored Feb 24, 2012
327 f.input :author, :as => :radio, :collection => User.all
a92cf7c @justinfrench added documentation for :collection option, resolves #181
authored Mar 13, 2010
328 f.input :author, :as => :radio, :collection => [@justin, @kate]
329 f.input :author, :as => :radio, :collection => { @justin.name => @justin.id, @kate.name => @kate.id }
330 f.input :author, :as => :radio, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
331 f.input :admin, :as => :radio, :collection => ["Yes!", "No"]
332 </pre>
333
6fd1bd2 @justinfrench improving the documentation in README
authored Apr 19, 2009
334
5a39443 @justinfrench bulking up the documentation and readme with the different inputs ava…
authored Jun 28, 2008
335 h2. The Available Inputs
336
d9a06fe @grimen README: Last set of polishing moves for now.
grimen authored Oct 25, 2009
337 The Formtastic input types:
338
8577c18 @grimen More README-readability polishing.
grimen authored Oct 25, 2009
339 * @:select@ - a select menu. Default for ActiveRecord associations: @belongs_to@, @has_many@, and @has_and_belongs_to_many@.
340 * @:check_boxes@ - a set of check_box inputs. Alternative to @:select@ for ActiveRecord-associations: @has_many@, and @has_and_belongs_to_many@.
341 * @:radio@ - a set of radio inputs. Alternative to @:select@ for ActiveRecord-associations: @belongs_to@.
342 * @:time_zone@ - a select input. Default for column types: @:string@ with name matching @"time_zone"@.
343 * @:password@ - a password input. Default for column types: @:string@ with name matching @"password"@.
344 * @:text@ - a textarea. Default for column types: @:text@.
345 * @:date@ - a date select. Default for column types: @:date@.
346 * @:datetime@ - a date and time select. Default for column types: @:datetime@ and @:timestamp@.
347 * @:time@ - a time select. Default for column types: @:time@.
348 * @:boolean@ - a checkbox. Default for column types: @:boolean@.
349 * @:string@ - a text field. Default for column types: @:string@.
a33f4d0 @justinfrench renamed NumericInput (:as => :numeric) to NumberInput (:as => :number)
authored Apr 5, 2011
350 * @:number@ - a text field (just like string). Default for column types: @:integer@, @:float@, and @:decimal@.
8577c18 @grimen More README-readability polishing.
grimen authored Oct 25, 2009
351 * @:file@ - a file field. Default for file-attachment attributes matching: "paperclip":http://github.com/thoughtbot/paperclip or "attachment_fu":http://github.com/technoweenie/attachment_fu.
352 * @:country@ - a select menu of country names. Default for column types: :string with name @"country"@ - requires a *country_select* plugin to be installed.
e0a7874 @asanghi Added auto-guessing and updated some docs
asanghi authored Oct 10, 2010
353 * @:email@ - a text field (just like string). Default for columns with name matching @"email"@. New in HTML5. Works on some mobile browsers already.
354 * @:url@ - a text field (just like string). Default for columns with name matching @"url"@. New in HTML5. Works on some mobile browsers already.
355 * @:phone@ - a text field (just like string). Default for columns with name matching @"phone"@ or @"fax"@. New in HTML5.
356 * @:search@ - a text field (just like string). Default for columns with name matching @"search"@. New in HTML5. Works on Safari.
6688887 @grimen More README-polishing.
grimen authored Oct 25, 2009
357 * @:hidden@ - a hidden field. Creates a hidden field (added for compatibility).
d877b6b @justinfrench Merge branch 'refactor' of https://github.com/okonski/formtastic into…
authored Apr 6, 2011
358 * @:range@ - a slider field.
6688887 @grimen More README-polishing.
grimen authored Oct 25, 2009
359
fd23ef4 @justinfrench tiny README tweak
authored Mar 13, 2010
360 The comments in the code are pretty good for each of these (what it does, what the output is, what the options are, etc.) so go check it out.
361
5a39443 @justinfrench bulking up the documentation and readme with the different inputs ava…
authored Jun 28, 2008
362
06ff25d @lardawge Added section clarifying label lookup order.
lardawge authored Dec 10, 2009
363 h2. Delegation for label lookups
364
365 Formtastic decides which label to use in the following order:
366
367 <pre>
368 1. :label # :label => "Choose Title"
369 2. Formtastic i18n # if either :label => true || i18n_lookups_by_default = true (see Internationalization)
370 3. Activerecord i18n # if localization file found for the given attribute
371 4. label_str_method # if nothing provided this defaults to :humanize but can be set to a custom method
372 </pre>
373
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 3, 2009
374 h2. Internationalization (I18n)
375
49a18a5 @grimen README-update: I18n instructions are better structured, and easier to…
grimen authored Oct 25, 2009
376 h3. Basic Localization
71ef99f @justinfrench nuked the configuration copy/paste from the README, linked to the gen…
authored Oct 21, 2009
377
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
378 Formtastic has some neat I18n-features. ActiveRecord object names and attributes are, by default, taken from calling @@object.human_name@ and @@object.human_attribute_name(attr)@ respectively. There are a few words specific to Formtastic that can be translated. See @lib/locale/en.yml@ for more information.
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
379
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
380 Basic localization (labels only, with ActiveRecord):
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
381
382 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
383 <%= semantic_form_for @post do |f| %>
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 27, 2011
384 <%= f.inputs do %>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
385 <%= f.input :title %> # => :label => I18n.t('activerecord.attributes.user.title') or 'Title'
386 <%= f.input :body %> # => :label => I18n.t('activerecord.attributes.user.body') or 'Body'
387 <%= f.input :section %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
600e013 @justinfrench always use inputs() block in README examples, less chance of WTF moments
authored Sep 27, 2011
388 <% end %>
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
389 <% end %>
390 </pre>
391
49a18a5 @grimen README-update: I18n instructions are better structured, and easier to…
grimen authored Oct 25, 2009
392 *Note:* This is perfectly fine if you just want your labels/attributes and/or models to be translated using *ActiveRecord I18n attribute translations*, and you don't use input hints and legends. But what if you do? And what if you don't want same labels in all forms?
393
394 h3. Enhanced Localization (Formtastic I18n API)
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
395
d9a06fe @grimen README: Last set of polishing moves for now.
grimen authored Oct 25, 2009
396 Formtastic supports localized *labels*, *hints*, *legends*, *actions* using the I18n API for more advanced usage. Your forms can now be DRYer and more flexible than ever, and still fully localized. This is how:
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
397
49a18a5 @grimen README-update: I18n instructions are better structured, and easier to…
grimen authored Oct 25, 2009
398 *1. Enable I18n lookups by default (@config/initializers/formtastic.rb@):*
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
399
400 <pre>
549ef7a @justinfrench Renamed all instances of Formtastic::SemanticFormBuilder to Formtasti…
authored Jan 18, 2011
401 Formtastic::FormBuilder.i18n_lookups_by_default = true
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
402 </pre>
403
49a18a5 @grimen README-update: I18n instructions are better structured, and easier to…
grimen authored Oct 25, 2009
404 *2. Add some cool label-translations/variants (@config/locale/en.yml@):*
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
405
406 <pre>
407 en:
408 formtastic:
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
409 titles:
410 post_details: "Post details"
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
411 labels:
412 post:
13164f7 @justinfrench Allow HTML5 placeholder attributes to be set on String-ish inputs (st…
authored Apr 5, 2011
413 title: "Your Title"
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
414 body: "Write something..."
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
415 edit:
416 title: "Edit title"
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
417 hints:
418 post:
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
419 title: "Choose a good title for your post."
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
420 body: "Write something inspiring here."
13164f7 @justinfrench Allow HTML5 placeholder attributes to be set on String-ish inputs (st…
authored Apr 5, 2011
421 placeholders:
422 post:
423 title: "Title your post"
424 slug: "Leave blank for an automatically generated slug"
425 user:
426 email: "you@yours.com"
4aca8cd @grimen New I18n-features:
grimen authored Oct 24, 2009
427 actions:
743b26b @yabawock Revert "Reverting two i18n patches pulled in from the rails3 branch w…
yabawock authored May 29, 2010
428 create: "Create my %{model}"
4aca8cd @grimen New I18n-features:
grimen authored Oct 24, 2009
429 update: "Save changes"
7723de7 @justinfrench Introducing actions for submit, cancel and reset buttons
authored Jan 11, 2012
430 reset: "Reset form"
431 cancel: "Cancel and go back"
4aca8cd @grimen New I18n-features:
grimen authored Oct 24, 2009
432 dummie: "Launch!"
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
433 </pre>
434
49a18a5 @grimen README-update: I18n instructions are better structured, and easier to…
grimen authored Oct 25, 2009
435 *3. ...and now you'll get:*
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
436
437 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
438 <%= semantic_form_for Post.new do |f| %>
439 <%= f.inputs do %>
440 <%= f.input :title %> # => :label => "Choose a title...", :hint => "Choose a good title for your post."
441 <%= f.input :body %> # => :label => "Write something...", :hint => "Write something inspiring here."
442 <%= f.input :section %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
443 <% end %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
444 <%= f.actions do %>
390ced4 @haines Minor formatting/typo fixes
haines authored Jan 16, 2012
445 <%= f.action :submit %> # => "Create my %{model}"
4aca8cd @grimen New I18n-features:
grimen authored Oct 24, 2009
446 <% end %>
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
447 <% end %>
448 </pre>
449
49a18a5 @grimen README-update: I18n instructions are better structured, and easier to…
grimen authored Oct 25, 2009
450 *4. Localized titles (a.k.a. legends):*
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
451
17f6668 @justinfrench Revert "This reverts commit 440bd2d."
authored Nov 21, 2009
452 _Note: Slightly different because Formtastic can't guess how you group fields in a form. Legend text can be set with first (as in the sample below) specified value, or :name/:title options - depending on what flavor is preferred._
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
453
454 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
455 <%= semantic_form_for @post do |f| %>
456 <%= f.inputs :post_details do %> # => :title => "Post details"
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
457 # ...
458 <% end %>
459 # ...
460 <% end %>
461 </pre>
462
49a18a5 @grimen README-update: I18n instructions are better structured, and easier to…
grimen authored Oct 25, 2009
463 *5. Override I18n settings:*
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
464
465 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
466 <%= semantic_form_for @post do |f| %>
467 <%= f.inputs do %>
468 <%= f.input :title %> # => :label => "Choose a title...", :hint => "Choose a good title for your post."
469 <%= f.input :body, :hint => false %> # => :label => "Write something..."
470 <%= f.input :section, :label => 'Some section' %> # => :label => 'Some section'
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
471 <% end %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
472 <%= f.actions do %>
390ced4 @haines Minor formatting/typo fixes
haines authored Jan 16, 2012
473 <%= f.action :submit, :label => :dummie %> # => "Launch!"
4aca8cd @grimen New I18n-features:
grimen authored Oct 24, 2009
474 <% end %>
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
475 <% end %>
476 </pre>
477
478 If I18n-lookups is disabled, i.e.:
479
480 <pre>
549ef7a @justinfrench Renamed all instances of Formtastic::SemanticFormBuilder to Formtasti…
authored Jan 18, 2011
481 Formtastic::FormBuilder.i18n_lookups_by_default = false
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
482 </pre>
483
484 ...then you can enable I18n within the forms instead:
485
486 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
487 <%= semantic_form_for @post do |f| %>
488 <%= f.inputs do %>
489 <%= f.input :title, :label => true %> # => :label => "Choose a title..."
490 <%= f.input :body, :label => true %> # => :label => "Write something..."
491 <%= f.input :section, :label => true %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
492 <% end %>
a429c6a @justinfrench change README to use actions instead of buttons
authored Jan 14, 2012
493 <%= f.actions do %>
494 <%= f.action :submit, :label => true %> # => "Update %{model}" (if we are in edit that is...)
4aca8cd @grimen New I18n-features:
grimen authored Oct 24, 2009
495 <% end %>
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
496 <% end %>
497 </pre>
498
49a18a5 @grimen README-update: I18n instructions are better structured, and easier to…
grimen authored Oct 25, 2009
499 *6. Advanced I18n lookups*
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
500
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
501 For more flexible forms; Formtastic finds translations using a bottom-up approach taking the following variables in account:
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
502
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
503 * @MODEL@, e.g. "post"
504 * @ACTION@, e.g. "edit"
4aca8cd @grimen New I18n-features:
grimen authored Oct 24, 2009
505 * @KEY/ATTRIBUTE@, e.g. "title", :my_custom_key, ...
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
506
507 ...in the following order:
508
6688887 @grimen More README-polishing.
grimen authored Oct 25, 2009
509 1. @formtastic.{titles,labels,hints,actions}.MODEL.ACTION.ATTRIBUTE@ - by model and action
510 2. @formtastic.{titles,labels,hints,actions}.MODEL.ATTRIBUTE@ - by model
511 3. @formtastic.{titles,labels,hints,actions}.ATTRIBUTE@ - global default
94ce3ec @grimen Documentation for the new I18n features for labels/hints.
grimen authored Aug 2, 2009
512
513 ...which means that you can define translations like this:
514
515 <pre>
516 en:
517 formtastic:
518 labels:
519 title: "Title" # Default global value
520 article:
521 body: "Article content"
522 post:
523 new:
524 title: "Choose a title..."
525 body: "Write something..."
526 edit:
527 title: "Edit title"
528 body: "Edit body"
529 </pre>
530
4aca8cd @grimen New I18n-features:
grimen authored Oct 24, 2009
531 Values for @labels@/@hints@/@actions@ are can take values: @String@ (explicit value), @Symbol@ (i18n-lookup-key relative to the current "type", e.g. actions:), @true@ (force I18n lookup), @false@ (force no I18n lookup). Titles (legends) can only take: @String@ and @Symbol@ - true/false have no meaning.
75782e1 @grimen Updated I18n-instructions in README; on the I18n-support for fieldset…
grimen authored Sep 16, 2009
532
71ef99f @justinfrench nuked the configuration copy/paste from the README, linked to the gen…
authored Oct 21, 2009
533
c4ebcef * added semantic_errors method with specs
Wojciech Wnętrzak authored Dec 3, 2009
534 h2. Semantic errors
535
536 You can show errors on base (by default) and any other attribute just passing it name to semantic_errors method:
537
538 <pre>
913215e @justinfrench use |f| consistently in README for form builder variable name
authored Sep 27, 2011
539 <%= semantic_form_for @post do |f| %>
540 <%= f.semantic_errors :state %>
c4ebcef * added semantic_errors method with specs
Wojciech Wnętrzak authored Dec 3, 2009
541 <% end %>
542 </pre>
543
544
7687bf7 @justinfrench Added support for modified and custom inputs in app/inputs/.
authored Apr 4, 2011
545 h2. Modified & Custom Inputs
ce7da5e @justinfrench added the builder config to the config template and quick documentati…
authored Nov 10, 2009
546
eb9e523 Better documentation for custom inputs
Nathan Long authored Sep 27, 2011
547 You can modify existing inputs, subclass them, or create your own from scratch. Here's the basic process:
548
549 * Create a file in @app/inputs@ with a filename ending in @_input.rb@. For example, @app/inputs/hat_size_input.rb@. Formtastic will automatically look in @app/inputs@ and find the file.
550 * In that file, declare a classname ending in @Input@. For example, @class HatSizeInput@. It must have a @to_html@ method for rendering.
551 * To use that input, leave off the word "input" in your @as@ statement. For example, @f.input(:size, :as => :hat_size)@
552
553 Specific examples follow.
554
555 h3. Changing Existing Input Behavior
556
557 To modify the behavior of @StringInput@, subclass it in a new file, @app/inputs/string_input.rb@:
ce7da5e @justinfrench added the builder config to the config template and quick documentati…
authored Nov 9, 2009
558
7687bf7 @justinfrench Added support for modified and custom inputs in app/inputs/.
authored Apr 4, 2011
559 <pre>
560 class StringInput < Formtastic::Inputs::StringInput
561 def to_html
562 puts "this is my modified version of StringInput"
563 super
564 end
565 end
566 </pre>
ce7da5e @justinfrench added the builder config to the config template and quick documentati…
authored Nov 9, 2009
567
eb9e523 Better documentation for custom inputs
Nathan Long authored Sep 27, 2011
568 You can use your modified version with @:as => :string@.
569
570 h3. Creating New Inputs Based on Existing Ones
571
572 To create your own new types of inputs based on existing inputs, the process is similar. For example, to create @FlexibleTextInput@ based on @StringInput@, put the following in @app/inputs/flexible_text_input.rb@:
ce7da5e @justinfrench added the builder config to the config template and quick documentati…
authored Nov 9, 2009
573
28bb57f @paneq Resolves http://github.com/justinfrench/formtastic/issues/#issue/409
paneq authored Nov 2, 2010
574 <pre>
d57c054 @robinst README: Fix mention of inexistent StringTextInput
robinst authored Jun 2, 2011
575 class FlexibleTextInput < Formtastic::Inputs::StringInput
7687bf7 @justinfrench Added support for modified and custom inputs in app/inputs/.
authored Apr 4, 2011
576 def input_html_options
577 super.merge(:class => "flexible-text-area")
578 end
579 end
28bb57f @paneq Resolves http://github.com/justinfrench/formtastic/issues/#issue/409
paneq authored Nov 2, 2010
580 </pre>
3f58f3a @justinfrench README update for --controller option form generator
authored Dec 3, 2009
581
eb9e523 Better documentation for custom inputs
Nathan Long authored Sep 27, 2011
582 You can use your new input with @:as => :flexible_text@.
583
584 h3. Creating New Inputs From Scratch
585
586 To create a custom @DatePickerInput@ from scratch, put the following in @app/inputs/date_picker_input.rb@:
7687bf7 @justinfrench Added support for modified and custom inputs in app/inputs/.
authored Apr 4, 2011
587
588 <pre>
34d6e16 @robinst README: Fix custom input example about DatePicker
robinst authored Jun 2, 2011
589 class DatePickerInput
590 include Formtastic::Inputs::Base
591 def to_html
592 # ...
7687bf7 @justinfrench Added support for modified and custom inputs in app/inputs/.
authored Apr 4, 2011
593 end
594 end
595 </pre>
596
eb9e523 Better documentation for custom inputs
Nathan Long authored Sep 27, 2011
597 You can use your new input with @:as => :date_picker@.
598
599 h3. Don't subclass Formtastic::FormBuilder anymore
600
22a9af1 @justinfrench prep README for 2.0
authored Sep 1, 2011
601 It was previously recommended in Formtastic 1.x to subclass Formtastic::FormBuilder to add your own inputs. This is no longer recommended in Formtastic 2, and will not work as expected.
7687bf7 @justinfrench Added support for modified and custom inputs in app/inputs/.
authored Apr 4, 2011
602
5f3d7a6 @justinfrench updated the generator docs in README to reflect both Rails 3 and 2
authored Sep 21, 2010
603
2d2d813 @yabawock More intelligent way to html_escape labels and hints (GH-299)
yabawock authored Jul 12, 2010
604 h2. Security
ce7da5e @justinfrench added the builder config to the config template and quick documentati…
authored Nov 9, 2009
605
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
606 By default, Formtastic escapes HTML entities in both labels and hints unless a string is marked as html_safe. If you are using an older rails version which doesn't know html_safe, or you want to globally turn this feature off, you can set the following in your initializer:
2d2d813 @yabawock More intelligent way to html_escape labels and hints (GH-299)
yabawock authored Jul 12, 2010
607
549ef7a @justinfrench Renamed all instances of Formtastic::SemanticFormBuilder to Formtasti…
authored Jan 18, 2011
608 Formtastic::FormBuilder.escape_html_entities_in_hints_and_labels = false
3f58f3a @justinfrench README update for --controller option form generator
authored Dec 2, 2009
609
610
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
611 h2. Dependencies
dcf8beb Initial Commit
Justin French authored Apr 7, 2008
612
9af5cc8 @justinfrench Big update and re-organization of the README:
authored Feb 28, 2009
613 There are none, but...
dcf8beb Initial Commit
Justin French authored Apr 7, 2008
614
64d55a8 Improve grammar, capitalization, formatting
Nathan Long authored Sep 26, 2011
615 * If you want to use the @:country@ input, you'll need to install the "country-select plugin":https://github.com/chrislerum/country_select (or any other country_select plugin with the same API).
1fcc068 @grimen An effort to make the README somewhat more readable.
grimen authored Oct 25, 2009
616 * "rspec":http://github.com/dchelimsky/rspec/, "rspec_hpricot_matchers":http://rubyforge.org/projects/rspec-hpricot/ and "rcov":http://github.com/relevance/rcov gems (plus any of their own dependencies) are required for the test suite.
dcf8beb Initial Commit
Justin French authored Apr 7, 2008
617
0b370ba @justinfrench Renamed input_field_set() to just inputs() and added a shorthand vers…
authored Jan 6, 2009
618
2079c59 @justinfrench added a section about contributing to README
authored Jan 2, 2010
619 h2. How to contribute
620
35e228e @justinfrench updates to README
authored Jan 15, 2012
621 * Fork the project on Github
622 * Create a topic branch for your changes
623 * Ensure that all tests pass (`bundle exec rake`)
624 * Ensure that the changes in your branch are as atomic as possible
625 * Create a pull request on Github
2079c59 @justinfrench added a section about contributing to README
authored Jan 1, 2010
626
35e228e @justinfrench updates to README
authored Jan 15, 2012
627 For significant changes, you may wish to discuss your idea on the Formtastic Google group before coding to ensure that your change is likely to be accepted. Formtastic relies heavily on i18n, so if you're unsure of the impact this has on your changes, please discuss them with the group.
533c086 @justinfrench added a section to the README on getting a dev environment up and run…
authored Nov 28, 2010
628
629
90282e3 @justinfrench added twitter account to the readme
authored Nov 9, 2010
630 h2. Google Group, Twitter, etc
5af0311 @justinfrench updated the README to pimp the google group more
authored Apr 2, 2009
631
632 Please join the "Formtastic Google Group":http://groups.google.com.au/group/formtastic, especially if you'd like to talk about a new feature, or report a bug.
633
35e228e @justinfrench updates to README
authored Jan 15, 2012
634 You can also follow "@justinfrench":http://twitter.com/formtastic or "@formtastic":http://twitter.com/formtastic on Twitter for announcements, tutorials and links.
90282e3 @justinfrench added twitter account to the readme
authored Nov 8, 2010
635
ba3ce05 @justinfrench updated the README a little with contributors and some other busy work
authored Jun 27, 2008
636 h2. Project Info
637
35e228e @justinfrench updates to README
authored Jan 15, 2012
638 Formtastic was created by "Justin French":http://www.justinfrench.com with contributions from around 150 awesome developers. Run @git shortlog -n -s@ to see the awesome.
ba3ce05 @justinfrench updated the README a little with contributors and some other busy work
authored Jun 27, 2008
639
eff38a1 @justinfrench too hard to maintain the maintainers
authored May 27, 2011
640 The project is hosted on Github: "http://github.com/justinfrench/formtastic":http://github.com/justinfrench/formtastic, where your contributions, forkings, comments, issues and feedback are greatly welcomed.
ba3ce05 @justinfrench updated the README a little with contributors and some other busy work
authored Jun 27, 2008
641
35e228e @justinfrench updates to README
authored Jan 15, 2012
642 Copyright (c) 2007-2012 Justin French, released under the MIT license.
Something went wrong with that request. Please try again.