Skip to content
This repository
Newer
Older
100644 578 lines (416 sloc) 25.022 kb
420b4ce7 »
2009-04-22 sick of updating the README with every version bump :)
1 h1. Formtastic
dcf8bebb » Justin French
2008-04-07 Initial Commit
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
09d957d0 » Justin French
2008-04-29 textilized the README so that it looks pretty pretty on GitHub
5 h2. The Story
dcf8bebb » Justin French
2008-04-07 Initial Commit
6
2d4a72b4 »
2009-02-16 big update to the README
7 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:
dcf8bebb » Justin French
2008-04-07 Initial Commit
8
09d957d0 » Justin French
2008-04-29 textilized the README so that it looks pretty pretty on GitHub
9 <pre>
7e3874a1 »
2008-08-13 trying to fix README formatting of <'s at the start of lines
10 <% semantic_form_for @article do |form| %>
353618ed » markmansour
2009-01-13 Extending Formtastic can be done by overriding the semantic_form_buil…
11
0b370bae »
2009-01-06 Renamed input_field_set() to just inputs() and added a shorthand vers…
12 <% form.inputs :name => "Basic" do %>
353618ed » markmansour
2009-01-13 Extending Formtastic can be done by overriding the semantic_form_buil…
13 <%= form.input :title %>
14 <%= form.input :body %>
1db292f7 » sprsquish
2009-02-28 update README to reflect association attribute changes
15 <%= form.input :section %>
16 <%= form.input :publication_state, :as => :radio %>
9997ce62 » josevalim
2009-03-07 Added more information about inputs :for in README.
17 <%= form.input :category %>
353618ed » markmansour
2009-01-13 Extending Formtastic can be done by overriding the semantic_form_buil…
18 <%= form.input :allow_comments, :label => "Allow commenting on this article" %>
19 <% end %>
20
0b370bae »
2009-01-06 Renamed input_field_set() to just inputs() and added a shorthand vers…
21 <% form.inputs :name => "Advanced" do %>
353618ed » markmansour
2009-01-13 Extending Formtastic can be done by overriding the semantic_form_buil…
22 <%= form.input :keywords, :required => false, :hint => "Example: ruby, rails, forms" %>
7e3874a1 »
2008-08-13 trying to fix README formatting of <'s at the start of lines
23 <%= form.input :extract, :required => false %>
24 <%= form.input :description, :required => false %>
353618ed » markmansour
2009-01-13 Extending Formtastic can be done by overriding the semantic_form_buil…
25 <%= form.input :url_title, :required => false %>
7e3874a1 »
2008-08-13 trying to fix README formatting of <'s at the start of lines
26 <% end %>
27
05ae54da » josevalim
2009-03-22 Fixed nested attributes example in README
28 <% form.inputs :name => "Author", :for => :author do |author_form| %>
29 <%= author_form.input :first_name %>
30 <%= author_form.input :last_name %>
9997ce62 » josevalim
2009-03-07 Added more information about inputs :for in README.
31 <% end %>
32
353618ed » markmansour
2009-01-13 Extending Formtastic can be done by overriding the semantic_form_buil…
33 <% form.buttons do %>
34 <%= form.commit_button %>
7e3874a1 »
2008-08-13 trying to fix README formatting of <'s at the start of lines
35 <% end %>
09d957d0 » Justin French
2008-04-29 textilized the README so that it looks pretty pretty on GitHub
36
dcf8bebb » Justin French
2008-04-07 Initial Commit
37 <% end %>
09d957d0 » Justin French
2008-04-29 textilized the README so that it looks pretty pretty on GitHub
38 </pre>
39
6734cfd2 »
2008-07-21 sme typos and cleanups in the readme
40 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.
dcf8bebb » Justin French
2008-04-07 Initial Commit
41
42
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
43 h2. It's better than _SomeOtherFormBuilder_ because...
44
66888879 » grimen
2009-10-25 More README-polishing.
45 * 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.
46 * 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.
47 * it's Rails 2.3-ready (including nested forms).
f02b1367 »
2009-03-01 rearranged and beefed up the 'it's better than...' README section
48 * it has internationalization (I18n)!
66888879 » grimen
2009-10-25 More README-polishing.
49 * 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.
50 * there's heaps of elements, id and class attributes for you to hook in your CSS and JS.
51 * it handles real world stuff like inline hints, inline error messages & help text.
52 * 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).
53 * it's got absolutely awesome spec coverage.
54 * there's a bunch of people using and working on it (it's not just one developer building half a solution).
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
55
56
15e0bd98 » Justin French
2008-05-30 updated the README a little to match last night's slides
57 h2. Why?
58
66888879 » grimen
2009-10-25 More README-polishing.
59 * web apps = lots of forms.
60 * forms are so friggin' boring to code.
61 * semantically rich & accessible forms really are possible.
62 * the "V" is way behind the "M" and "C" in Rails' MVC – it's the ugly sibling.
63 * best practices and common patterns have to start somewhere.
64 * i need a challenge.
dcf8bebb » Justin French
2008-04-07 Initial Commit
65
66
15e0bd98 » Justin French
2008-05-30 updated the README a little to match last night's slides
67 h2. Opinions
68
66888879 » grimen
2009-10-25 More README-polishing.
69 * it should be easier to do things the right way than the wrong way.
70 * sometimes _more mark-up_ is better.
71 * elements and attribute hooks are _gold_ for stylesheet authors.
72 * make the common things we do easy, yet still ensure uncommon things are still possible.
15e0bd98 » Justin French
2008-05-30 updated the README a little to match last night's slides
73
dcf8bebb » Justin French
2008-04-07 Initial Commit
74
3dd64554 »
2009-07-03 Link to RDoc URL in README
75 h2. Documentation
76
77 RDoc documentation _should_ be automatically generated after each commit and made available on the "rdoc.info website":http://rdoc.info/projects/justinfrench/formtastic.
78
79
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
80 h2. Gems and Bundles
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
81
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
82 Formtastic is now compatible with both Rails 2 and Rails 3, and the gem is "hosted":http://rubygems.org/gems/formtastic on RubyGems.org.
4036e741 »
2010-07-21 pruning and cleaning up the README, it's been a while
83
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
84
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
85 h4. For Rails 3 (or Rails 2 with Bundler)
557f9295 »
2010-08-28 updated README to reflect new 1.1.0.beta gem, etc
86
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
87 Simply add Formtastic to your Gemfile and bundle it up:
557f9295 »
2010-08-28 updated README to reflect new 1.1.0.beta gem, etc
88
89 <pre>
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
90 gem 'formtastic', '~> 1.1.0'
557f9295 »
2010-08-28 updated README to reflect new 1.1.0.beta gem, etc
91 </pre>
92
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
93 Optionally, run @rails generate formtastic:install@ to copy some stylesheets and a configuration initializer into your application.
4036e741 »
2010-07-21 pruning and cleaning up the README, it's been a while
94
95
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
96 h4. For Rails 2:
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
97
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
98 Install the gem:
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
99
100 <pre>
2bf5b23b »
2009-10-21 updated README to reflect gemcutter gem source
101 sudo gem install formtastic
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
102 </pre>
103
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
104 And add the gem to your environment.rb configuration as a gem dependency:
6ae6675d »
2010-01-07 adding config.gem instructions to README, thanks Tom White
105
106 <pre>
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
107 config.gem 'formtastic', '~> 1.1.0'
6ae6675d »
2010-01-07 adding config.gem instructions to README, thanks Tom White
108 </pre>
109
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
110 Optionally, run @./script/generate formtastic@ to copy some stylesheets and a configuration initializer into your application.
fc29eaaf »
2009-10-11 Combined the "formtastic_config" and "formtastic_stylesheets" generat…
111
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
112
113 h2. Stylesheets
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
114
127a6b98 »
2010-01-10 Added a Formtastic::LayoutHelper with formtastic_stylesheets so that …
115 A proof-of-concept stylesheet is provided which you can include in your layout. Customization is best achieved by overriding these styles in an additional stylesheet so that the Formtastic styles can be updated without clobbering your changes. If you want to use these stylesheets, add both to your layout with this helper:
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
116
5c1ce48a »
2009-10-21 moved the stylesheets stuff up with installation
117 <pre>
127a6b98 »
2010-01-10 Added a Formtastic::LayoutHelper with formtastic_stylesheets so that …
118 <head>
119 ...
120 <%= formtastic_stylesheet_link_tag %>
121 ...
122 </head>
5c1ce48a »
2009-10-21 moved the stylesheets stuff up with installation
123 </pre>
2526d2c1 »
2009-10-11 Going back to generators instead of Rake tasks for copying stylesheet…
124
4036e741 »
2010-07-21 pruning and cleaning up the README, it's been a while
125
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
126 h2. Usage
127
128 Forms are really boring to code... you want to get onto the good stuff as fast as possible.
129
66888879 » grimen
2009-10-25 More README-polishing.
130 This renders a set of inputs (one for _most_ columns in the database table, and one for each ActiveRecord @belongs_to@-association), followed by a submit button:
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
131
132 <pre>
133 <% semantic_form_for @user do |form| %>
134 <%= form.inputs %>
135 <%= form.buttons %>
136 <% end %>
137 </pre>
138
139 If you want to specify the order of the fields, skip some of the fields or even add in fields that Formtastic couldn't detect, you can pass in a list of field names to @inputs@ and list of button names to @buttons@:
140
141 <pre>
142 <% semantic_form_for @user do |form| %>
143 <%= form.inputs :title, :body, :section, :categories, :created_at %>
144 <%= form.buttons :commit %>
145 <% end %>
146 </pre>
147
66888879 » grimen
2009-10-25 More README-polishing.
148 If you want control over the input type Formtastic uses for each field, you can expand the @inputs@ and @buttons@ blocks. This specifies the @:section@ input should be a set of radio buttons (rather than the default select box), and that the @:created_at@ field should be a string (rather than the default datetime selects):
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
149
150 <pre>
151 <% semantic_form_for @post do |form| %>
152 <% form.inputs do %>
153 <%= form.input :title %>
154 <%= form.input :body %>
155 <%= form.input :section, :as => :radio %>
156 <%= form.input :categories %>
157 <%= form.input :created_at, :as => :string %>
158 <% end %>
159 <% form.buttons do %>
160 <%= form.commit_button %>
161 <% end %>
162 <% end %>
163 </pre>
164
a45853c5 »
2009-04-19 small README typo
165 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:
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
166
167 <pre>
168 <% semantic_form_for @post do |form| %>
17f66680 »
2009-11-21 Revert "This reverts commit 440bd2d."
169 <% form.inputs "Basic", :id => "basic" do %>
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
170 <%= form.input :title %>
171 <%= form.input :body %>
172 <% end %>
173 <% form.inputs :name => "Advanced Options", :id => "advanced" do %>
174 <%= form.input :slug, :label => "URL Title", :hint => "Created automatically if left blank", :required => false %>
175 <%= form.input :section, :as => :radio %>
176 <%= form.input :user, :label => "Author", :label_method => :full_name, %>
177 <%= form.input :categories, :required => false %>
178 <%= form.input :created_at, :as => :string, :label => "Publication Date", :required => false %>
179 <% end %>
180 <% form.buttons do %>
181 <%= form.commit_button %>
182 <% end %>
183 <% end %>
184 </pre>
185
4db9cfe1 »
2010-03-17 tweaked README to include accepts_nested_attributes_for mention
186 Nested forms (Rails 2.3) are also supported (don't forget your models need to be setup correctly with accepts_nested_attributes_for – search the Rails docs). You can do it in the Rails way:
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
187
188 <pre>
05ae54da » josevalim
2009-03-22 Fixed nested attributes example in README
189 <% semantic_form_for @post do |form| %>
190 <%= form.inputs :title, :body, :created_at %>
41a67543 » josevalim
2009-03-24 Another README fix.
191 <% form.semantic_fields_for :author do |author| %>
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
192 <%= author.inputs :first_name, :last_name, :name => "Author" %>
41a67543 » josevalim
2009-03-24 Another README fix.
193 <% end %>
05ae54da » josevalim
2009-03-22 Fixed nested attributes example in README
194 <%= form.buttons %>
9997ce62 » josevalim
2009-03-07 Added more information about inputs :for in README.
195 <% end %>
196 </pre>
197
6fd1bd27 »
2009-04-19 improving the documentation in README
198 Or the Formtastic way with the @:for@ option:
9997ce62 » josevalim
2009-03-07 Added more information about inputs :for in README.
199
200 <pre>
05ae54da » josevalim
2009-03-22 Fixed nested attributes example in README
201 <% semantic_form_for @post do |form| %>
202 <%= form.inputs :title, :body, :created_at %>
203 <%= form.inputs :first_name, :last_name, :for => :author, :name => "Author" %>
204 <%= form.buttons %>
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
205 <% end %>
206 </pre>
207
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
208 When working in has many association, you can even supply @"%i"@ in your fieldset name that it will be properly interpolated with the child index. For example:
d5e3b0a0 » josevalim
2009-03-24 Added nested child nindex support.
209
210 <pre>
211 <% semantic_form_for @post do |form| %>
212 <%= form.inputs %>
213 <%= form.inputs :name => 'Category #%i', :for => :categories %>
214 <%= form.buttons %>
215 <% end %>
216 </pre>
217
6fd1bd27 »
2009-04-19 improving the documentation in README
218
29133e1a » dougireton
2010-04-28 Fixed minor typo in README Usage section.
219 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/autogrow textareas:
6fd1bd27 »
2009-04-19 improving the documentation in README
220
221 <pre>
222 <% semantic_form_for @post do |form| %>
223 <%= form.input :title, :input_html => { :size => 60 } %>
224 <%= form.input :body, :input_html => { :class => 'autogrow' } %>
225 <%= form.input :created_at, :input_html => { :disabled => true } %>
226 <%= form.buttons %>
227 <% end %>
228 </pre>
229
230 The same can be done for buttons with the @:button_html@ option:
231
232 <pre>
233 <% semantic_form_for @post do |form| %>
234 ...
235 <% form.buttons do %>
236 <%= form.commit_button :button_html => { :class => "primary" } %>
237 <% end %>
238 <% end %>
239 </pre>
240
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
241 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"@)
242
6fd1bd27 »
2009-04-19 improving the documentation in README
243 <pre>
244 <% semantic_form_for @post do |form| %>
245 <%= form.input :title, :wrapper_html => { :class => "important" } %>
246 <%= form.input :body %>
247 <%= form.input :description, :wrapper_html => { :style => "display:none;" } %>
248 ...
249 <% end %>
250 </pre>
251
a92cf7cb »
2010-03-13 added documentation for :collection option, resolves #181
252 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:
253
254 <pre>
255 f.input :authors, :as => :check_boxes, :collection => User.find(:all, :order => "last_name ASC")
256 f.input :authors, :as => :check_boxes, :collection => current_user.company.users.active
257 f.input :authors, :as => :check_boxes, :collection => [@justin, @kate]
258 f.input :authors, :as => :check_boxes, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
259 f.input :author, :as => :select, :collection => Author.find(:all)
260 f.input :author, :as => :select, :collection => { @justin.name => @justin.id, @kate.name => @kate.id }
261 f.input :author, :as => :select, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
262 f.input :author, :as => :radio, :collection => User.find(:all)
263 f.input :author, :as => :radio, :collection => [@justin, @kate]
264 f.input :author, :as => :radio, :collection => { @justin.name => @justin.id, @kate.name => @kate.id }
265 f.input :author, :as => :radio, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
266 f.input :admin, :as => :radio, :collection => ["Yes!", "No"]
267 </pre>
268
6fd1bd27 »
2009-04-19 improving the documentation in README
269
5a394436 »
2008-06-28 bulking up the documentation and readme with the different inputs ava…
270 h2. The Available Inputs
271
d9a06fe5 » grimen
2009-10-25 README: Last set of polishing moves for now.
272 The Formtastic input types:
273
8577c184 » grimen
2009-10-25 More README-readability polishing.
274 * @:select@ - a select menu. Default for ActiveRecord associations: @belongs_to@, @has_many@, and @has_and_belongs_to_many@.
275 * @:check_boxes@ - a set of check_box inputs. Alternative to @:select@ for ActiveRecord-associations: @has_many@, and @has_and_belongs_to_many@.
276 * @:radio@ - a set of radio inputs. Alternative to @:select@ for ActiveRecord-associations: @belongs_to@.
277 * @:time_zone@ - a select input. Default for column types: @:string@ with name matching @"time_zone"@.
278 * @:password@ - a password input. Default for column types: @:string@ with name matching @"password"@.
279 * @:text@ - a textarea. Default for column types: @:text@.
280 * @:date@ - a date select. Default for column types: @:date@.
281 * @:datetime@ - a date and time select. Default for column types: @:datetime@ and @:timestamp@.
282 * @:time@ - a time select. Default for column types: @:time@.
283 * @:boolean@ - a checkbox. Default for column types: @:boolean@.
284 * @:string@ - a text field. Default for column types: @:string@.
285 * @:numeric@ - a text field (just like string). Default for column types: @:integer@, @:float@, and @:decimal@.
286 * @: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.
287 * @:country@ - a select menu of country names. Default for column types: :string with name @"country"@ - requires a *country_select* plugin to be installed.
66888879 » grimen
2009-10-25 More README-polishing.
288 * @:hidden@ - a hidden field. Creates a hidden field (added for compatibility).
289
fd23ef4f »
2010-03-13 tiny README tweak
290 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.
291
5a394436 »
2008-06-28 bulking up the documentation and readme with the different inputs ava…
292
06ff25d8 » lardawge
2009-12-10 Added section clarifying label lookup order.
293 h2. Delegation for label lookups
294
295 Formtastic decides which label to use in the following order:
296
297 <pre>
298 1. :label # :label => "Choose Title"
299 2. Formtastic i18n # if either :label => true || i18n_lookups_by_default = true (see Internationalization)
300 3. Activerecord i18n # if localization file found for the given attribute
301 4. label_str_method # if nothing provided this defaults to :humanize but can be set to a custom method
302 </pre>
303
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
304 h2. Internationalization (I18n)
305
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
306 h3. Basic Localization
71ef99fd »
2009-10-21 nuked the configuration copy/paste from the README, linked to the gen…
307
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
308 Formtastic got 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.
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
309
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
310 Basic localization (labels only, with ActiveRecord):
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
311
312 <pre>
313 <% semantic_form_for @post do |form| %>
314 <%= form.input :title %> # => :label => I18n.t('activerecord.attributes.user.title') or 'Title'
315 <%= form.input :body %> # => :label => I18n.t('activerecord.attributes.user.body') or 'Body'
316 <%= form.input :section %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
317 <% end %>
318 </pre>
319
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
320 *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?
321
322 h3. Enhanced Localization (Formtastic I18n API)
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
323
d9a06fe5 » grimen
2009-10-25 README: Last set of polishing moves for now.
324 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:
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
325
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
326 *1. Enable I18n lookups by default (@config/initializers/formtastic.rb@):*
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
327
328 <pre>
329 Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true
330 </pre>
331
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
332 *2. Add some cool label-translations/variants (@config/locale/en.yml@):*
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
333
334 <pre>
335 en:
336 formtastic:
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
337 titles:
338 post_details: "Post details"
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
339 labels:
340 post:
341 title: "Choose a title..."
342 body: "Write something..."
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
343 edit:
344 title: "Edit title"
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
345 hints:
346 post:
347 title: "Choose a good title for you post."
348 body: "Write something inspiring here."
4aca8cd4 » grimen
2009-10-24 New I18n-features:
349 actions:
743b26b9 » yabawock
2010-05-29 Revert "Reverting two i18n patches pulled in from the rails3 branch w…
350 create: "Create my %{model}"
4aca8cd4 » grimen
2009-10-24 New I18n-features:
351 update: "Save changes"
352 dummie: "Launch!"
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
353 </pre>
354
355 *Note:* We are using English here still, but you get the point.
356
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
357 *3. ...and now you'll get:*
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
358
359 <pre>
4aca8cd4 » grimen
2009-10-24 New I18n-features:
360 <% semantic_form_for Post.new do |form| %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
361 <% form.inputs do %>
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
362 <%= form.input :title %> # => :label => "Choose a title...", :hint => "Choose a good title for you post."
363 <%= form.input :body %> # => :label => "Write something...", :hint => "Write something inspiring here."
364 <%= form.input :section %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
365 <% end %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
366 <% form.buttons do %>
743b26b9 » yabawock
2010-05-29 Revert "Reverting two i18n patches pulled in from the rails3 branch w…
367 <%= form.commit_button %> # => "Create my %{model}"
4aca8cd4 » grimen
2009-10-24 New I18n-features:
368 <% end %>
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
369 <% end %>
370 </pre>
371
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
372 *4. Localized titles (a.k.a. legends):*
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
373
17f66680 »
2009-11-21 Revert "This reverts commit 440bd2d."
374 _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._
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
375
376 <pre>
377 <% semantic_form_for @post do |form| %>
17f66680 »
2009-11-21 Revert "This reverts commit 440bd2d."
378 <% form.inputs :post_details do %> # => :title => "Post details"
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
379 # ...
380 <% end %>
381 # ...
382 <% end %>
383 </pre>
384
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
385 *5. Override I18n settings:*
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
386
387 <pre>
388 <% semantic_form_for @post do |form| %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
389 <% form.inputs do %>
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
390 <%= form.input :title %> # => :label => "Choose a title...", :hint => "Choose a good title for you post."
391 <%= form.input :body, :hint => false %> # => :label => "Write something..."
392 <%= form.input :section, :label => 'Some section' %> # => :label => 'Some section'
393 <% end %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
394 <% form.buttons do %>
4aca8cd4 » grimen
2009-10-24 New I18n-features:
395 <%= form.commit_button :dummie %> # => "Launch!"
396 <% end %>
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
397 <% end %>
398 </pre>
399
400 If I18n-lookups is disabled, i.e.:
401
402 <pre>
403 Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
404 </pre>
405
406 ...then you can enable I18n within the forms instead:
407
408 <pre>
409 <% semantic_form_for @post do |form| %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
410 <% form.inputs do %>
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
411 <%= form.input :title, :label => true %> # => :label => "Choose a title..."
412 <%= form.input :body, :label => true %> # => :label => "Write something..."
413 <%= form.input :section, :label => true %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
414 <% end %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
415 <% form.buttons do %>
4aca8cd4 » grimen
2009-10-24 New I18n-features:
416 <%= form.commit_button true %> # => "Save changes" (if we are in edit that is...)
417 <% end %>
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
418 <% end %>
419 </pre>
420
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
421 *6. Advanced I18n lookups*
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
422
423 For more flexible forms; Formtastic find translations using a bottom-up approach taking the following variables in account:
424
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
425 * @MODEL@, e.g. "post"
426 * @ACTION@, e.g. "edit"
4aca8cd4 » grimen
2009-10-24 New I18n-features:
427 * @KEY/ATTRIBUTE@, e.g. "title", :my_custom_key, ...
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
428
429 ...in the following order:
430
66888879 » grimen
2009-10-25 More README-polishing.
431 1. @formtastic.{titles,labels,hints,actions}.MODEL.ACTION.ATTRIBUTE@ - by model and action
432 2. @formtastic.{titles,labels,hints,actions}.MODEL.ATTRIBUTE@ - by model
433 3. @formtastic.{titles,labels,hints,actions}.ATTRIBUTE@ - global default
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
434
435 ...which means that you can define translations like this:
436
437 <pre>
438 en:
439 formtastic:
440 labels:
441 title: "Title" # Default global value
442 article:
443 body: "Article content"
444 post:
445 new:
446 title: "Choose a title..."
447 body: "Write something..."
448 edit:
449 title: "Edit title"
450 body: "Edit body"
451 </pre>
452
4aca8cd4 » grimen
2009-10-24 New I18n-features:
453 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.
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
454
71ef99fd »
2009-10-21 nuked the configuration copy/paste from the README, linked to the gen…
455
c4ebcefd » Wojciech Wnętrzak
2009-12-03 * added semantic_errors method with specs
456 h2. Semantic errors
457
458 You can show errors on base (by default) and any other attribute just passing it name to semantic_errors method:
459
460 <pre>
461 <% semantic_form_for @post do |form| %>
462 <%= form.semantic_errors :state %>
463 <% end %>
464 </pre>
465
466
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
467 h2. ValidationReflection plugin
468
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
469 If you have the "ValidationReflection":http://github.com/redinger/validation_reflection plugin installed, you won't have to specify the @:required@ option (it checks the validations on the model instead).
5a394436 »
2008-06-28 bulking up the documentation and readme with the different inputs ava…
470
471
71ef99fd »
2009-10-21 nuked the configuration copy/paste from the README, linked to the gen…
472 h2. Configuration
5a394436 »
2008-06-28 bulking up the documentation and readme with the different inputs ava…
473
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
474 Run @./script/generate formtastic@ to copy a commented out config file into @config/initializers/formtastic.rb@. You can "view the configuration file on GitHub":http://github.com/justinfrench/formtastic/blob/master/generators/formtastic/templates/formtastic.rb
3a32b4a8 » josevalim
2009-03-04 Updated README with new configuration options.
475
5a394436 »
2008-06-28 bulking up the documentation and readme with the different inputs ava…
476
fef3288b » grimen
2009-11-19 Added documentation for the form generator in README, and showing som…
477 h2. Form Generator
478
479 There's a Formtastic form code generator to make your transition to Formtastic easier. All you have to do is to *specify an existing model name*, and optionally specify view template framework (ERB/HAML), and you are good to go. *Note:* This won't overwrite any of you stuff. This is how you use it:
480
481 *Alt. 1: Generate in terminal:*
482
483 <pre>
484 $ ./script/generate form Post
485 # ---------------------------------------------------------
486 # GENERATED FORMTASTIC CODE
487 # ---------------------------------------------------------
488
e57b9d1c » grimen
2009-12-17 Form generator: |f| is a better default for |form|. Also works better…
489 <% f.inputs do %>
490 <%= f.input :title, :label => 'Title' %>
491 <%= f.input :body, :label => 'Body' %>
492 <%= f.input :published, :label => 'Published' %>
fef3288b » grimen
2009-11-19 Added documentation for the form generator in README, and showing som…
493 <% end %>
494
495 # ---------------------------------------------------------
496 Copied to clipboard - just paste it!
497 </pre>
498
499 *Alt. 2: Generate partial:*
500
501 <pre>
502 $ ./script/generate form Post --partial
503 exists app/views/posts
504 create app/views/posts/_form.html.erb
505 </pre>
506
3f58f3a5 »
2009-12-03 README update for --controller option form generator
507 To generate *HAML* markup, just add the @--haml@ as argument:
508
509 <pre>
510 $ ./script/generate form Post --haml
511 exists app/views/admin/posts
512 create app/views/admin/posts/_form.html.haml
513 </pre>
514
515 To specify the controller in a namespace (eg admin/posts instead of posts), use the --controller argument:
516
517 <pre>
518 $ ./script/generate form Post --partial --controller admin/posts
519 exists app/views/admin/posts
520 create app/views/admin/posts/_form.html.erb
521 </pre>
522
fef3288b » grimen
2009-11-19 Added documentation for the form generator in README, and showing som…
523
ce7da5e9 »
2009-11-10 added the builder config to the config template and quick documentati…
524 h2. Custom Inputs
525
526 If you want to add your own input types to encapsulate your own logic or interface patterns, you can do so by subclassing SemanticFormBuilder and configuring Formtastic to use your custom builder class.
527
528 @Formtastic::SemanticFormHelper.builder = MyCustomBuilder@
529
2d2d8131 » yabawock
2010-07-12 More intelligent way to html_escape labels and hints (GH-299)
530 h2. Security
ce7da5e9 »
2009-11-10 added the builder config to the config template and quick documentati…
531
2d2d8131 » yabawock
2010-07-12 More intelligent way to html_escape labels and hints (GH-299)
532 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:
533
534 Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = false
3f58f3a5 »
2009-12-03 README update for --controller option form generator
535
536
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
537 h2. Dependencies
dcf8bebb » Justin French
2008-04-07 Initial Commit
538
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
539 There are none, but...
dcf8bebb » Justin French
2008-04-07 Initial Commit
540
e9f27cf3 » grimen
2009-11-28 The most tiny README-update ever. =)
541 * if you have the "ValidationReflection":http://github.com/redinger/validation_reflection plugin is installed, you won't have to specify the @:required@ option (it checks the validations on the model instead).
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
542 * if you want to use the @:country@ input, you'll need to install the "iso-3166-country-select plugin":http://github.com/rails/iso-3166-country-select (or any other country_select plugin with the same API).
543 * "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.
dcf8bebb » Justin French
2008-04-07 Initial Commit
544
0b370bae »
2009-01-06 Renamed input_field_set() to just inputs() and added a shorthand vers…
545
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
546 h2. Compatibility
0b370bae »
2009-01-06 Renamed input_field_set() to just inputs() and added a shorthand vers…
547
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
548 * We're only testing Formtastic with the latest Rails 2.x and 3.x stable releases. Patches are welcome to allow backwards compatibility with older versions of Rails, of course.
eab18fa1 »
2010-08-12 prep README for 1.0
549 * Formtastic, much like Rails 2, is very ActiveRecord-centric. Many people are using Formtastic (especially the rails3 branch) successfully with other ActiveModel-like ORMs and classes (DataMapper, MongoMapper, Mongoid, Authlogic, Devise...) but we're not guaranteeing anything at this stage. Patches are welcome, but it's not our core focus right now.
4036e741 »
2010-07-21 pruning and cleaning up the README, it's been a while
550
61d00565 »
2009-10-21 * updated the status to reflect that this is a release candidate
551
2079c593 »
2010-01-02 added a section about contributing to README
552 h2. How to contribute
553
4036e741 »
2010-07-21 pruning and cleaning up the README, it's been a while
554 Please ensure that you provide appropriate spec/test coverage and ensure the documentation is up-to-date. Bonus points if you perform your changes in a clean topic branch rather than master, and if you create an issue on GH for us to discuss your changes. Pull requests tend to get lost.
2079c593 »
2010-01-02 added a section about contributing to README
555
556 Please also keep your commits *atomic* so that they are more likely to apply cleanly. That means that each commit should contain the smallest possible logical change. Don't commit two features at once, don't update the gemspec at the same time you add a feature, don't fix a whole bunch of whitespace in a file at the same time you change a few lines, etc, etc.
557
558 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.
559
560
259a98c4 »
2010-01-02 updated heading in README
561 h2. Maintainers & Contributors
83b9eb17 »
2009-04-02 updated the contributors list
562
644d1001 » yabawock
2010-07-22 Fix typo in Readme
563 Formtastic is maintained by "Justin French":http://github.com/justinfrench, "Morton Jonuschat":http://github.com/yabawock and "Gabriel Sobrinho":http://github.com/sobrinho. "Denis Major":http://github.com/denismajor1 is doing some amazing documentation work in the wiki, and we very much appreciate the past efforts of "José Valim":http://github.com/josevalim and "Jonas Grimfelt":http://github.com/grimen and over 40 other contributors.
619ce6cc »
2009-11-10 added Grimen to the README, updated contributors list, etc
564
565 @git shortlog -n -s --no-merges@
2d4a72b4 »
2009-02-16 big update to the README
566
5af03110 »
2009-04-02 updated the README to pimp the google group more
567
7a84a73e »
2009-11-10 README heading tweak
568 h2. Google Group
5af03110 »
2009-04-02 updated the README to pimp the google group more
569
570 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.
571
572
ba3ce055 »
2008-06-27 updated the README a little with contributors and some other busy work
573 h2. Project Info
574
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
575 Formtastic is hosted on Github: "http://github.com/justinfrench/formtastic":http://github.com/justinfrench/formtastic, where your contributions, forkings, comments and feedback are greatly welcomed.
ba3ce055 »
2008-06-27 updated the README a little with contributors and some other busy work
576
577
ebe4e51c »
2010-09-08 updated the README to reflect the new gem versions and other compatib…
578 Copyright (c) 2007-2010 Justin French, released under the MIT license.
Something went wrong with that request. Please try again.