Skip to content
This repository
Newer
Older
100644 537 lines (385 sloc) 22.216 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
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
80 h2. Installation
81
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
82 The gem is hosted on gemcutter, so *if you haven't already*, add it as a gem source:
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
83
84 <pre>
2bf5b23b »
2009-10-21 updated README to reflect gemcutter gem source
85 sudo gem sources -a http://gemcutter.org/
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
86 </pre>
87
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
88 Then install the Formtastic gem:
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
89
90 <pre>
2bf5b23b »
2009-10-21 updated README to reflect gemcutter gem source
91 sudo gem install formtastic
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
92 </pre>
93
2bf5b23b »
2009-10-21 updated README to reflect gemcutter gem source
94 Optionally, run @./script/generate formtastic@ to copy the following files into your app:
fc29eaaf »
2009-10-11 Combined the "formtastic_config" and "formtastic_stylesheets" generat…
95
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
96 * @config/initializers/formtastic.rb@ - a commented out Formtastic config initializer
97 * @public/stylesheets/formtastic.css@
98 * @public/stylesheets/formtastic_changes.css@
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
99
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
100 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:
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
101
5c1ce48a »
2009-10-21 moved the stylesheets stuff up with installation
102 <pre>
103 <%= stylesheet_link_tag "formtastic" %>
104 <%= stylesheet_link_tag "formtastic_changes" %>
105 </pre>
2526d2c1 »
2009-10-11 Going back to generators instead of Rake tasks for copying stylesheet…
106
c89e9853 »
2009-03-08 updating README with gem/plugin installation instructions
107
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
108 h2. Usage
109
110 Forms are really boring to code... you want to get onto the good stuff as fast as possible.
111
66888879 » grimen
2009-10-25 More README-polishing.
112 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:
113
114 <pre>
115 <% semantic_form_for @user do |form| %>
116 <%= form.inputs %>
117 <%= form.buttons %>
118 <% end %>
119 </pre>
120
121 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@:
122
123 <pre>
124 <% semantic_form_for @user do |form| %>
125 <%= form.inputs :title, :body, :section, :categories, :created_at %>
126 <%= form.buttons :commit %>
127 <% end %>
128 </pre>
129
66888879 » grimen
2009-10-25 More README-polishing.
130 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:
131
132 <pre>
133 <% semantic_form_for @post do |form| %>
134 <% form.inputs do %>
135 <%= form.input :title %>
136 <%= form.input :body %>
137 <%= form.input :section, :as => :radio %>
138 <%= form.input :categories %>
139 <%= form.input :created_at, :as => :string %>
140 <% end %>
141 <% form.buttons do %>
142 <%= form.commit_button %>
143 <% end %>
144 <% end %>
145 </pre>
146
a45853c5 »
2009-04-19 small README typo
147 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:
148
149 <pre>
150 <% semantic_form_for @post do |form| %>
17f66680 »
2009-11-21 Revert "This reverts commit 440bd2d."
151 <% form.inputs "Basic", :id => "basic" do %>
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
152 <%= form.input :title %>
153 <%= form.input :body %>
154 <% end %>
155 <% form.inputs :name => "Advanced Options", :id => "advanced" do %>
156 <%= form.input :slug, :label => "URL Title", :hint => "Created automatically if left blank", :required => false %>
157 <%= form.input :section, :as => :radio %>
158 <%= form.input :user, :label => "Author", :label_method => :full_name, %>
159 <%= form.input :categories, :required => false %>
160 <%= form.input :created_at, :as => :string, :label => "Publication Date", :required => false %>
161 <% end %>
162 <% form.buttons do %>
163 <%= form.commit_button %>
164 <% end %>
165 <% end %>
166 </pre>
167
9997ce62 » josevalim
2009-03-07 Added more information about inputs :for in README.
168 Nested forms (Rails 2.3) are also supported. You can do it in the Rails way:
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
169
170 <pre>
05ae54da » josevalim
2009-03-22 Fixed nested attributes example in README
171 <% semantic_form_for @post do |form| %>
172 <%= form.inputs :title, :body, :created_at %>
41a67543 » josevalim
2009-03-24 Another README fix.
173 <% form.semantic_fields_for :author do |author| %>
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
174 <%= author.inputs :first_name, :last_name, :name => "Author" %>
41a67543 » josevalim
2009-03-24 Another README fix.
175 <% end %>
05ae54da » josevalim
2009-03-22 Fixed nested attributes example in README
176 <%= form.buttons %>
9997ce62 » josevalim
2009-03-07 Added more information about inputs :for in README.
177 <% end %>
178 </pre>
179
6fd1bd27 »
2009-04-19 improving the documentation in README
180 Or the Formtastic way with the @:for@ option:
9997ce62 » josevalim
2009-03-07 Added more information about inputs :for in README.
181
182 <pre>
05ae54da » josevalim
2009-03-22 Fixed nested attributes example in README
183 <% semantic_form_for @post do |form| %>
184 <%= form.inputs :title, :body, :created_at %>
185 <%= form.inputs :first_name, :last_name, :for => :author, :name => "Author" %>
186 <%= form.buttons %>
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
187 <% end %>
188 </pre>
189
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
190 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.
191
192 <pre>
193 <% semantic_form_for @post do |form| %>
194 <%= form.inputs %>
195 <%= form.inputs :name => 'Category #%i', :for => :categories %>
196 <%= form.buttons %>
197 <% end %>
198 </pre>
199
6fd1bd27 »
2009-04-19 improving the documentation in README
200
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
201 Customize HTML attributes for any input using the @:input_html@ option. Typically his 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
202
203 <pre>
204 <% semantic_form_for @post do |form| %>
205 <%= form.input :title, :input_html => { :size => 60 } %>
206 <%= form.input :body, :input_html => { :class => 'autogrow' } %>
207 <%= form.input :created_at, :input_html => { :disabled => true } %>
208 <%= form.buttons %>
209 <% end %>
210 </pre>
211
212 The same can be done for buttons with the @:button_html@ option:
213
214 <pre>
215 <% semantic_form_for @post do |form| %>
216 ...
217 <% form.buttons do %>
218 <%= form.commit_button :button_html => { :class => "primary" } %>
219 <% end %>
220 <% end %>
221 </pre>
222
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
223 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"@)
224
6fd1bd27 »
2009-04-19 improving the documentation in README
225 <pre>
226 <% semantic_form_for @post do |form| %>
227 <%= form.input :title, :wrapper_html => { :class => "important" } %>
228 <%= form.input :body %>
229 <%= form.input :description, :wrapper_html => { :style => "display:none;" } %>
230 ...
231 <% end %>
232 </pre>
233
234
5a394436 »
2008-06-28 bulking up the documentation and readme with the different inputs ava…
235 h2. The Available Inputs
236
d9a06fe5 » grimen
2009-10-25 README: Last set of polishing moves for now.
237 The Formtastic input types:
238
8577c184 » grimen
2009-10-25 More README-readability polishing.
239 * @:select@ - a select menu. Default for ActiveRecord associations: @belongs_to@, @has_many@, and @has_and_belongs_to_many@.
240 * @:check_boxes@ - a set of check_box inputs. Alternative to @:select@ for ActiveRecord-associations: @has_many@, and @has_and_belongs_to_many@.
241 * @:radio@ - a set of radio inputs. Alternative to @:select@ for ActiveRecord-associations: @belongs_to@.
242 * @:time_zone@ - a select input. Default for column types: @:string@ with name matching @"time_zone"@.
243 * @:password@ - a password input. Default for column types: @:string@ with name matching @"password"@.
244 * @:text@ - a textarea. Default for column types: @:text@.
245 * @:date@ - a date select. Default for column types: @:date@.
246 * @:datetime@ - a date and time select. Default for column types: @:datetime@ and @:timestamp@.
247 * @:time@ - a time select. Default for column types: @:time@.
248 * @:boolean@ - a checkbox. Default for column types: @:boolean@.
249 * @:string@ - a text field. Default for column types: @:string@.
250 * @:numeric@ - a text field (just like string). Default for column types: @:integer@, @:float@, and @:decimal@.
251 * @: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.
252 * @: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.
253 * @:hidden@ - a hidden field. Creates a hidden field (added for compatibility).
254
255 The documentation is pretty good for each of these (what it does, what the output is, what the options are, etc.) so go check it out.
5a394436 »
2008-06-28 bulking up the documentation and readme with the different inputs ava…
256
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
257 h2. Internationalization (I18n)
258
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
259 h3. Basic Localization
71ef99fd »
2009-10-21 nuked the configuration copy/paste from the README, linked to the gen…
260
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
261 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.
262
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
263 Basic localization (labels only, with ActiveRecord):
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
264
265 <pre>
266 <% semantic_form_for @post do |form| %>
267 <%= form.input :title %> # => :label => I18n.t('activerecord.attributes.user.title') or 'Title'
268 <%= form.input :body %> # => :label => I18n.t('activerecord.attributes.user.body') or 'Body'
269 <%= form.input :section %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
270 <% end %>
271 </pre>
272
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
273 *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?
274
275 h3. Enhanced Localization (Formtastic I18n API)
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
276
d9a06fe5 » grimen
2009-10-25 README: Last set of polishing moves for now.
277 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.
278
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
279 *1. Enable I18n lookups by default (@config/initializers/formtastic.rb@):*
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
280
281 <pre>
282 Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true
283 </pre>
284
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
285 *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.
286
287 <pre>
288 en:
289 formtastic:
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
290 titles:
291 post_details: "Post details"
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
292 labels:
293 post:
294 title: "Choose a title..."
295 body: "Write something..."
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
296 edit:
297 title: "Edit title"
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
298 hints:
299 post:
300 title: "Choose a good title for you post."
301 body: "Write something inspiring here."
4aca8cd4 » grimen
2009-10-24 New I18n-features:
302 actions:
303 create: "Create my {{model}}"
304 update: "Save changes"
305 dummie: "Launch!"
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
306 </pre>
307
308 *Note:* We are using English here still, but you get the point.
309
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
310 *3. ...and now you'll get:*
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
311
312 <pre>
4aca8cd4 » grimen
2009-10-24 New I18n-features:
313 <% semantic_form_for Post.new do |form| %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
314 <% form.inputs do %>
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
315 <%= form.input :title %> # => :label => "Choose a title...", :hint => "Choose a good title for you post."
316 <%= form.input :body %> # => :label => "Write something...", :hint => "Write something inspiring here."
317 <%= form.input :section %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
318 <% end %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
319 <% form.buttons do %>
4aca8cd4 » grimen
2009-10-24 New I18n-features:
320 <%= form.commit_button %> # => "Create my {{model}}"
321 <% end %>
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
322 <% end %>
323 </pre>
324
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
325 *4. Localized titles (a.k.a. legends):*
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
326
17f66680 »
2009-11-21 Revert "This reverts commit 440bd2d."
327 _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…
328
329 <pre>
330 <% semantic_form_for @post do |form| %>
17f66680 »
2009-11-21 Revert "This reverts commit 440bd2d."
331 <% form.inputs :post_details do %> # => :title => "Post details"
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
332 # ...
333 <% end %>
334 # ...
335 <% end %>
336 </pre>
337
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
338 *5. Override I18n settings:*
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
339
340 <pre>
341 <% semantic_form_for @post do |form| %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
342 <% form.inputs do %>
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
343 <%= form.input :title %> # => :label => "Choose a title...", :hint => "Choose a good title for you post."
344 <%= form.input :body, :hint => false %> # => :label => "Write something..."
345 <%= form.input :section, :label => 'Some section' %> # => :label => 'Some section'
346 <% end %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
347 <% form.buttons do %>
4aca8cd4 » grimen
2009-10-24 New I18n-features:
348 <%= form.commit_button :dummie %> # => "Launch!"
349 <% end %>
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
350 <% end %>
351 </pre>
352
353 If I18n-lookups is disabled, i.e.:
354
355 <pre>
356 Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
357 </pre>
358
359 ...then you can enable I18n within the forms instead:
360
361 <pre>
362 <% semantic_form_for @post do |form| %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
363 <% form.inputs do %>
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
364 <%= form.input :title, :label => true %> # => :label => "Choose a title..."
365 <%= form.input :body, :label => true %> # => :label => "Write something..."
366 <%= form.input :section, :label => true %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
367 <% end %>
a8e2f2ee »
2009-11-10 fix README examples missing form.x prefix for buttons and inputs
368 <% form.buttons do %>
4aca8cd4 » grimen
2009-10-24 New I18n-features:
369 <%= form.commit_button true %> # => "Save changes" (if we are in edit that is...)
370 <% end %>
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
371 <% end %>
372 </pre>
373
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
374 *6. Advanced I18n lookups*
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
375
376 For more flexible forms; Formtastic find translations using a bottom-up approach taking the following variables in account:
377
75782e15 » grimen
2009-09-16 Updated I18n-instructions in README; on the I18n-support for fieldset…
378 * @MODEL@, e.g. "post"
379 * @ACTION@, e.g. "edit"
4aca8cd4 » grimen
2009-10-24 New I18n-features:
380 * @KEY/ATTRIBUTE@, e.g. "title", :my_custom_key, ...
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
381
382 ...in the following order:
383
66888879 » grimen
2009-10-25 More README-polishing.
384 1. @formtastic.{titles,labels,hints,actions}.MODEL.ACTION.ATTRIBUTE@ - by model and action
385 2. @formtastic.{titles,labels,hints,actions}.MODEL.ATTRIBUTE@ - by model
386 3. @formtastic.{titles,labels,hints,actions}.ATTRIBUTE@ - global default
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
387
388 ...which means that you can define translations like this:
389
390 <pre>
391 en:
392 formtastic:
393 labels:
394 title: "Title" # Default global value
395 article:
396 body: "Article content"
397 post:
398 new:
399 title: "Choose a title..."
400 body: "Write something..."
401 edit:
402 title: "Edit title"
403 body: "Edit body"
404 </pre>
405
4aca8cd4 » grimen
2009-10-24 New I18n-features:
406 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…
407
71ef99fd »
2009-10-21 nuked the configuration copy/paste from the README, linked to the gen…
408
c4ebcefd » Wojciech Wnętrzak
2009-12-03 * added semantic_errors method with specs
409 h2. Semantic errors
410
411 You can show errors on base (by default) and any other attribute just passing it name to semantic_errors method:
412
413 <pre>
414 <% semantic_form_for @post do |form| %>
415 <%= form.semantic_errors :state %>
416 <% end %>
417 </pre>
418
419
94ce3eca » grimen
2009-08-03 Documentation for the new I18n features for labels/hints.
420 h2. ValidationReflection plugin
421
49a18a52 » grimen
2009-10-25 README-update: I18n instructions are better structured, and easier to…
422 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…
423
424
71ef99fd »
2009-10-21 nuked the configuration copy/paste from the README, linked to the gen…
425 h2. Configuration
5a394436 »
2008-06-28 bulking up the documentation and readme with the different inputs ava…
426
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
427 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.
428
5a394436 »
2008-06-28 bulking up the documentation and readme with the different inputs ava…
429
fef3288b » grimen
2009-11-19 Added documentation for the form generator in README, and showing som…
430 h2. Form Generator
431
432 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:
433
434 *Alt. 1: Generate in terminal:*
435
436 <pre>
437 $ ./script/generate form Post
438 # ---------------------------------------------------------
439 # GENERATED FORMTASTIC CODE
440 # ---------------------------------------------------------
441
e57b9d1c » grimen
2009-12-17 Form generator: |f| is a better default for |form|. Also works better…
442 <% f.inputs do %>
443 <%= f.input :title, :label => 'Title' %>
444 <%= f.input :body, :label => 'Body' %>
445 <%= f.input :published, :label => 'Published' %>
fef3288b » grimen
2009-11-19 Added documentation for the form generator in README, and showing som…
446 <% end %>
447
448 # ---------------------------------------------------------
449 Copied to clipboard - just paste it!
450 </pre>
451
452 *Alt. 2: Generate partial:*
453
454 <pre>
455 $ ./script/generate form Post --partial
456 exists app/views/posts
457 create app/views/posts/_form.html.erb
458 </pre>
459
3f58f3a5 »
2009-12-03 README update for --controller option form generator
460 To generate *HAML* markup, just add the @--haml@ as argument:
461
462 <pre>
463 $ ./script/generate form Post --haml
464 exists app/views/admin/posts
465 create app/views/admin/posts/_form.html.haml
466 </pre>
467
468 To specify the controller in a namespace (eg admin/posts instead of posts), use the --controller argument:
469
470 <pre>
471 $ ./script/generate form Post --partial --controller admin/posts
472 exists app/views/admin/posts
473 create app/views/admin/posts/_form.html.erb
474 </pre>
475
fef3288b » grimen
2009-11-19 Added documentation for the form generator in README, and showing som…
476
ce7da5e9 »
2009-11-10 added the builder config to the config template and quick documentati…
477 h2. Custom Inputs
478
479 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.
480
481 @Formtastic::SemanticFormHelper.builder = MyCustomBuilder@
482
483
3f58f3a5 »
2009-12-03 README update for --controller option form generator
484
485
09d957d0 » Justin French
2008-04-29 textilized the README so that it looks pretty pretty on GitHub
486 h2. Status
dcf8bebb » Justin French
2008-04-07 Initial Commit
487
66888879 » grimen
2009-10-25 More README-polishing.
488 Formtastic has been in active development for about a year. We've just recently jumped to an 0.9 version number, signaling that we consider this a 1.0 release candidate, and that the API won't change significantly for the 1.x series.
c5d02e69 »
2009-02-16 link to the wiki for the roadmap to 1.0 in README
489
dcf8bebb » Justin French
2008-04-07 Initial Commit
490
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
491 h2. Dependencies
dcf8bebb » Justin French
2008-04-07 Initial Commit
492
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
493 There are none, but...
dcf8bebb » Justin French
2008-04-07 Initial Commit
494
e9f27cf3 » grimen
2009-11-28 The most tiny README-update ever. =)
495 * 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.
496 * 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).
497 * "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
498
0b370bae »
2009-01-06 Renamed input_field_set() to just inputs() and added a shorthand vers…
499
9af5cc8c »
2009-02-28 Big update and re-organization of the README:
500 h2. Compatibility
0b370bae »
2009-01-06 Renamed input_field_set() to just inputs() and added a shorthand vers…
501
d7fff769 »
2009-11-10 updated compatability guidelines
502 I'm only testing Formtastic with the latest Rails 2.4.x stable release, and it should be fine under Rails 2.3.x as well (including nested forms). Patches are welcome to allow backwards compatibility, but I don't have the energy!
0b370bae »
2009-01-06 Renamed input_field_set() to just inputs() and added a shorthand vers…
503
67a799f5 » grimen
2009-09-03 Made method_required? respect the :if conditional on validates_presen…
504 h2. Got TextMate?
505
66888879 » grimen
2009-10-25 More README-polishing.
506 Well...there's a TextMate-bundle in town, dedicated to make usage of Formtastic in the "TextMate":http://macromates.com/ editor even more of a breeze:
67a799f5 » grimen
2009-09-03 Made method_required? respect the :if conditional on validates_presen…
507
508 "Formtastic.tmbundle":http://github.com/grimen/formtastic_tmbundle
2d4a72b4 »
2009-02-16 big update to the README
509
61d00565 »
2009-10-21 * updated the status to reflect that this is a release candidate
510
2079c593 »
2010-01-02 added a section about contributing to README
511 h2. How to contribute
512
513 *Before you send a pull request*, 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.
514
515 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.
516
517 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.
518
519
83b9eb17 »
2009-04-02 updated the contributors list
520 h2. Contributors
521
619ce6cc »
2009-11-10 added Grimen to the README, updated contributors list, etc
522 Formtastic is maintained by "Justin French":http://justinfrench.com, "José Valim":http://github.com/josevalim and "Jonas Grimfelt":http://github.com/grimen, but it wouldn't be as awesome as it is today without help from over 30 contributors.
523
524 @git shortlog -n -s --no-merges@
2d4a72b4 »
2009-02-16 big update to the README
525
5af03110 »
2009-04-02 updated the README to pimp the google group more
526
7a84a73e »
2009-11-10 README heading tweak
527 h2. Google Group
5af03110 »
2009-04-02 updated the README to pimp the google group more
528
529 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.
530
531
ba3ce055 »
2008-06-27 updated the README a little with contributors and some other busy work
532 h2. Project Info
533
1fcc0681 » grimen
2009-10-25 An effort to make the README somewhat more readable.
534 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
535
536
25d0c7aa »
2008-12-08 fleshed out a 'roadmap to 1.0' in the README
537 Copyright (c) 2007-2008 Justin French, released under the MIT license.
Something went wrong with that request. Please try again.