jgdavey-formtastic 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Justin French
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,388 @@
1
+ h1. Formtastic
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
+
5
+ h2. The Story
6
+
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:
8
+
9
+ <pre>
10
+ <% semantic_form_for @article do |form| %>
11
+
12
+ <% form.inputs :name => "Basic" do %>
13
+ <%= form.input :title %>
14
+ <%= form.input :body %>
15
+ <%= form.input :section %>
16
+ <%= form.input :publication_state, :as => :radio %>
17
+ <%= form.input :category %>
18
+ <%= form.input :allow_comments, :label => "Allow commenting on this article" %>
19
+ <% end %>
20
+
21
+ <% form.inputs :name => "Advanced" do %>
22
+ <%= form.input :keywords, :required => false, :hint => "Example: ruby, rails, forms" %>
23
+ <%= form.input :extract, :required => false %>
24
+ <%= form.input :description, :required => false %>
25
+ <%= form.input :url_title, :required => false %>
26
+ <% end %>
27
+
28
+ <% form.inputs :name => "Author", :for => :author do |author_form| %>
29
+ <%= author_form.input :first_name %>
30
+ <%= author_form.input :last_name %>
31
+ <% end %>
32
+
33
+ <% form.buttons do %>
34
+ <%= form.commit_button %>
35
+ <% end %>
36
+
37
+ <% end %>
38
+ </pre>
39
+
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.
41
+
42
+
43
+ h2. It's better than _SomeOtherFormBuilder_ because...
44
+
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)
48
+ * it has internationalization (I18n)!
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)
55
+
56
+
57
+ h2. Why?
58
+
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
65
+
66
+
67
+ h2. Opinions
68
+
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
73
+
74
+
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
+
80
+ h2. Installation
81
+
82
+ You can (and should) get it as a gem:
83
+
84
+ <pre>
85
+ gem install justinfrench-formtastic
86
+ </pre>
87
+
88
+ And then add it as a dependency in your environment.rb file:
89
+
90
+ <pre>
91
+ config.gem "justinfrench-formtastic",
92
+ :lib => 'formtastic',
93
+ :source => 'http://gems.github.com'
94
+ </pre>
95
+
96
+ If you're a little more old school, install it as a plugin:
97
+
98
+ <pre>
99
+ ./script/plugin install git://github.com/justinfrench/formtastic.git
100
+ </pre>
101
+
102
+
103
+ h2. Usage
104
+
105
+ Forms are really boring to code... you want to get onto the good stuff as fast as possible.
106
+
107
+ 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:
108
+
109
+ <pre>
110
+ <% semantic_form_for @user do |form| %>
111
+ <%= form.inputs %>
112
+ <%= form.buttons %>
113
+ <% end %>
114
+ </pre>
115
+
116
+ 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@:
117
+
118
+ <pre>
119
+ <% semantic_form_for @user do |form| %>
120
+ <%= form.inputs :title, :body, :section, :categories, :created_at %>
121
+ <%= form.buttons :commit %>
122
+ <% end %>
123
+ </pre>
124
+
125
+ 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):
126
+
127
+ <pre>
128
+ <% semantic_form_for @post do |form| %>
129
+ <% form.inputs do %>
130
+ <%= form.input :title %>
131
+ <%= form.input :body %>
132
+ <%= form.input :section, :as => :radio %>
133
+ <%= form.input :categories %>
134
+ <%= form.input :created_at, :as => :string %>
135
+ <% end %>
136
+ <% form.buttons do %>
137
+ <%= form.commit_button %>
138
+ <% end %>
139
+ <% end %>
140
+ </pre>
141
+
142
+ 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:
143
+
144
+ <pre>
145
+ <% semantic_form_for @post do |form| %>
146
+ <% form.inputs :name => "Basic", :id => "basic" do %>
147
+ <%= form.input :title %>
148
+ <%= form.input :body %>
149
+ <% end %>
150
+ <% form.inputs :name => "Advanced Options", :id => "advanced" do %>
151
+ <%= form.input :slug, :label => "URL Title", :hint => "Created automatically if left blank", :required => false %>
152
+ <%= form.input :section, :as => :radio %>
153
+ <%= form.input :user, :label => "Author", :label_method => :full_name, %>
154
+ <%= form.input :categories, :required => false %>
155
+ <%= form.input :created_at, :as => :string, :label => "Publication Date", :required => false %>
156
+ <% end %>
157
+ <% form.buttons do %>
158
+ <%= form.commit_button %>
159
+ <% end %>
160
+ <% end %>
161
+ </pre>
162
+
163
+
164
+ Nested forms (Rails 2.3) are also supported. You can do it in the Rails way:
165
+
166
+ <pre>
167
+ <% semantic_form_for @post do |form| %>
168
+ <%= form.inputs :title, :body, :created_at %>
169
+ <% form.semantic_fields_for :author do |author| %>
170
+ <%= author.inputs :first_name, :last_name, :name => 'Author' %>
171
+ <% end %>
172
+ <%= form.buttons %>
173
+ <% end %>
174
+ </pre>
175
+
176
+ Or the Formtastic way with the @:for@ option:
177
+
178
+ <pre>
179
+ <% semantic_form_for @post do |form| %>
180
+ <%= form.inputs :title, :body, :created_at %>
181
+ <%= form.inputs :first_name, :last_name, :for => :author, :name => "Author" %>
182
+ <%= form.buttons %>
183
+ <% end %>
184
+ </pre>
185
+
186
+ 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:
187
+
188
+ <pre>
189
+ <% semantic_form_for @post do |form| %>
190
+ <%= form.inputs %>
191
+ <%= form.inputs :name => 'Category #%i', :for => :categories %>
192
+ <%= form.buttons %>
193
+ <% end %>
194
+ </pre>
195
+
196
+
197
+ 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:
198
+
199
+ <pre>
200
+ <% semantic_form_for @post do |form| %>
201
+ <%= form.input :title, :input_html => { :size => 60 } %>
202
+ <%= form.input :body, :input_html => { :class => 'autogrow' } %>
203
+ <%= form.input :created_at, :input_html => { :disabled => true } %>
204
+ <%= form.buttons %>
205
+ <% end %>
206
+ </pre>
207
+
208
+ The same can be done for buttons with the @:button_html@ option:
209
+
210
+ <pre>
211
+ <% semantic_form_for @post do |form| %>
212
+ ...
213
+ <% form.buttons do %>
214
+ <%= form.commit_button :button_html => { :class => "primary" } %>
215
+ <% end %>
216
+ <% end %>
217
+ </pre>
218
+
219
+ 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")
220
+
221
+ <pre>
222
+ <% semantic_form_for @post do |form| %>
223
+ <%= form.input :title, :wrapper_html => { :class => "important" } %>
224
+ <%= form.input :body %>
225
+ <%= form.input :description, :wrapper_html => { :style => "display:none;" } %>
226
+ ...
227
+ <% end %>
228
+ </pre>
229
+
230
+
231
+
232
+ h2. The Available Inputs
233
+
234
+ * :select (a select menu) - default for ActiveRecord associations (belongs_to, has_many, has_and_belongs_to_many)
235
+ * :check_boxes (a set of check_box inputs) - alternative to :select has_many and has_and_belongs_to_many associations
236
+ * :radio (a set of radio inputs) - alternative to :select for ActiveRecord belongs_to associations
237
+ * :time_zone (a select input) - default for :string column types with 'time_zone' in the method name
238
+ * :password (a password input) - default for :string column types with 'password' in the method name
239
+ * :text (a textarea) - default for :text column types
240
+ * :date (a date select) - default for :date column types
241
+ * :datetime (a date and time select) - default for :datetime and :timestamp column types
242
+ * :time (a time select) - default for :time column types
243
+ * :boolean (a checkbox) - default for :boolean column types
244
+ * :string (a text field) - default for :string column types
245
+ * :numeric (a text field, like string) - default for :integer, :float and :decimal column types
246
+ * :file (a file field) - default for paperclip or attachment_fu attributes
247
+ * :country (a select menu of country names) - default for :string columns named "country", requires a country_select plugin to be installed
248
+ * :hidden (a hidden field) - creates a hidden field (added for compatibility)
249
+
250
+
251
+ 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.
252
+
253
+
254
+ h2. Configuration
255
+
256
+ If you wish, put something like this in config/initializers/formtastic_config.rb:
257
+
258
+ <pre>
259
+ # Set the default text field size when input is a string. Default is 50
260
+ Formtastic::SemanticFormBuilder.default_text_field_size = 30
261
+
262
+ # Should all fields be considered "required" by default
263
+ # Defaults to true, see ValidationReflection notes below
264
+ Formtastic::SemanticFormBuilder.all_fields_required_by_default = false
265
+
266
+ # Set the string that will be appended to the labels/fieldsets which are required
267
+ # It accepts string or procs and the default is a localized version of
268
+ # '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
269
+ # in your locale, it will replace the abbr title properly. But if you don't want to use
270
+ # abbr tag, you can simply give a string as below
271
+ Formtastic::SemanticFormBuilder.required_string = "(required)"
272
+
273
+ # Set the string that will be appended to the labels/fieldsets which are optional
274
+ # Defaults to an empty string ("") and also accepts procs (see required_string above)
275
+ Formtastic::SemanticFormBuilder.optional_string = "(optional)"
276
+
277
+ # Set the way inline errors will be displayed.
278
+ # Defaults to :sentence, valid options are :sentence, :list and :none
279
+ Formtastic::SemanticFormBuilder.inline_errors = :list
280
+
281
+ # Set the method to call on label text to transform or format it for human-friendly
282
+ # reading when formtastic is user without object. Defaults to :humanize.
283
+ Formtastic::SemanticFormBuilder.label_str_method = :titleize
284
+
285
+ # Set the array of methods to try calling on parent objects in :select and :radio inputs
286
+ # for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
287
+ # that is found on the object will be used.
288
+ # Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
289
+ Formtastic::SemanticFormBuilder.collection_label_methods = ["title_and_author", "display_name", "login", "to_s"]
290
+
291
+ # Formtastic by default renders inside li tags the input, hints and then
292
+ # errors messages. Sometimes you want the hints to be rendered first than
293
+ # the input, in the following order: hints, input and errors. You can
294
+ # customize it doing just as below:
295
+ Formtastic::SemanticFormBuilder.inline_order = [:hints, :input, :errors]
296
+
297
+ # Set the default "priority countries" to suit your user base when using :as => :country
298
+ Formtastic::SemanticFormBuilder.priority_countries = ["Australia", "New Zealand"]
299
+ </pre>
300
+
301
+
302
+ h2. Internationalization (I18n)
303
+
304
+ Supports I18n! 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.
305
+
306
+
307
+ h2. ValidationReflection plugin
308
+
309
+ 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).
310
+
311
+
312
+ h2. Status
313
+
314
+ *THINGS ARE GOING TO CHANGE A BIT BEFORE WE HIT 1.0.*
315
+
316
+ It's a work in progress and a bit rough around the edges still, but I hope you try it and offer some suggestions and improvements anyway.
317
+
318
+ On the plus side, it has a comprehensive spec suite and contributions from at least ten independent developers.
319
+
320
+ "Wishlist":http://wiki.github.com/justinfrench/formtastic/wishlist on the wiki is serving as pretty good documentation for the roadmap to 1.0 and beyond right now, but I'll work on getting a real tracking system or something happening soon.
321
+
322
+
323
+ h2. Dependencies
324
+
325
+ There are none, but...
326
+
327
+ * 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)
328
+ * 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)
329
+ * rspec, rspec_hpricot_matchers and rcov gems (plus any of their own dependencies) are required for the test suite
330
+
331
+
332
+ h2. Compatibility
333
+
334
+ I'm only testing Formtastic with the latest Rails 2.2.x stable release, and it should be fine under Rails 2.3 as well (including nested forms). Patches are welcome to allow backwards compatibility, but I don't have the energy!
335
+
336
+
337
+
338
+ h2. What about Stylesheets?
339
+
340
+ A proof-of-concept (very much a work-in-progress) 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.
341
+
342
+ 1. Use the generator to copy the formtastic.css and formtastic_changes.css into your public directory
343
+
344
+ <pre>
345
+ ./script/generate formtastic_stylesheets
346
+ </pre>
347
+
348
+ 2. Add both formtastic.css and formtastic_changes.css to your layout:
349
+
350
+ <pre>
351
+ <%= stylesheet_link_tag "formtastic" %>
352
+ <%= stylesheet_link_tag "formtastic_changes" %>
353
+ </pre>
354
+
355
+
356
+ h2. Contributors
357
+
358
+ Formtastic is maintained by "Justin French":http://justinfrench.com and "José Valim":http://github.com/josevalim, but it wouldn't be as awesome as it is today if it weren't for the wonderful contributions of these fine, fine coders.
359
+
360
+ * "Jeff Smick":http://github.com/sprsquish
361
+ * "Tien Dung":http://github.com/tiendung
362
+ * "Mark Mansour":http://stateofflux.com
363
+ * "Andy Pearson":http://github.com/andypearson
364
+ * "negonicrac":http://github.com/negonicrac
365
+ * "Xavier Shay":http://rhnh.net
366
+ * "Pat Allan":http://github.com/freelancing-god
367
+ * "Gareth Townsend":http://github.com/quamen
368
+ * "Sascha Hoellger":http://github.com/mitnal
369
+ * "Andrew Carpenter":http://github.com/andrewcarpenter
370
+ * "Jack Dempsey":http://github.com/jackdempsey/
371
+ * "Greg Fitzgerald":http://github.com/gregf/
372
+ * "Hector E. Gomez Morales":http://github.com/hectoregm
373
+ * "Ben Hamill":http://blog.benhamill.com/
374
+ * "Simon Chiu":http://github.com/tolatomeow
375
+ * "Bin Dong":http://github.com/dongbin
376
+
377
+
378
+ h2. Hey, join the Google group!
379
+
380
+ 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.
381
+
382
+
383
+ h2. Project Info
384
+
385
+ Formtastic is hosted on Github: http://github.com/justinfrench/formtastic/, where your contributions, forkings, comments and feedback are greatly welcomed.
386
+
387
+
388
+ Copyright (c) 2007-2008 Justin French, released under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ require 'rake'
2
+ require 'rake/rdoctask'
3
+ require 'spec/rake/spectask'
4
+
5
+ begin
6
+ GEM = "formtastic"
7
+ AUTHOR = "Justin French"
8
+ EMAIL = "justin@indent.com.au"
9
+ SUMMARY = "A Rails form builder plugin/gem with semantically rich and accessible markup"
10
+ HOMEPAGE = "http://github.com/justinfrench/formtastic/tree/master"
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |s|
14
+ s.name = GEM
15
+ s.summary = SUMMARY
16
+ s.email = EMAIL
17
+ s.homepage = HOMEPAGE
18
+ s.description = SUMMARY
19
+ s.author = AUTHOR
20
+
21
+ s.require_path = 'lib'
22
+ s.autorequire = GEM
23
+ s.files = %w(MIT-LICENSE README.textile Rakefile) + Dir.glob("{rails,lib,generators,spec}/**/*")
24
+ end
25
+ rescue LoadError
26
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
27
+ end
28
+
29
+ desc 'Default: run unit specs.'
30
+ task :default => :spec
31
+
32
+ desc 'Test the formtastic plugin.'
33
+ Spec::Rake::SpecTask.new('spec') do |t|
34
+ t.spec_files = FileList['spec/**/*_spec.rb']
35
+ t.spec_opts = ["-c"]
36
+ end
37
+
38
+ desc 'Test the formtastic plugin with specdoc formatting and colors'
39
+ Spec::Rake::SpecTask.new('specdoc') do |t|
40
+ t.spec_files = FileList['spec/**/*_spec.rb']
41
+ t.spec_opts = ["--format specdoc", "-c"]
42
+ end
43
+
44
+ desc 'Generate documentation for the formtastic plugin.'
45
+ Rake::RDocTask.new(:rdoc) do |rdoc|
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = 'Formtastic'
48
+ rdoc.options << '--line-numbers' << '--inline-source'
49
+ rdoc.rdoc_files.include('README.textile')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
52
+
53
+ desc "Run all examples with RCov"
54
+ Spec::Rake::SpecTask.new('examples_with_rcov') do |t|
55
+ t.spec_files = FileList['spec/**/*_spec.rb']
56
+ t.rcov = true
57
+ t.rcov_opts = ['--exclude', 'spec,Library']
58
+ end
@@ -0,0 +1,21 @@
1
+ class FormtasticStylesheetsGenerator < Rails::Generator::Base
2
+
3
+ def initialize(*runtime_args)
4
+ super
5
+ end
6
+
7
+ def manifest
8
+ record do |m|
9
+ m.directory File.join('public', 'stylesheets')
10
+ m.template 'formtastic.css', File.join('public', 'stylesheets', 'formtastic.css')
11
+ m.template 'formtastic_changes.css', File.join('public', 'stylesheets', 'formtastic_changes.css')
12
+ end
13
+ end
14
+
15
+ protected
16
+
17
+ def banner
18
+ %{Usage: #{$0} #{spec.name}\nCopies formtastic.css and formtastic_changes.css to public/}
19
+ end
20
+
21
+ end
@@ -0,0 +1,136 @@
1
+ /* -------------------------------------------------------------------------------------------------
2
+
3
+ It's *strongly* suggested that you don't modify this file. Instead, load a new stylesheet after
4
+ this one in your layouts (eg formtastic_changes.css) and override the styles to suit your needs.
5
+ This will allow you to update formtastic.css with new releases without clobbering your own changes.
6
+
7
+ This stylesheet forms part of the Formtastic Rails Plugin
8
+ (c) 2008 Justin French
9
+
10
+ --------------------------------------------------------------------------------------------------*/
11
+
12
+
13
+ /* NORMALIZE AND RESET - obviously inspired by Yahoo's reset.css, but scoped to just form.formtastic
14
+ --------------------------------------------------------------------------------------------------*/
15
+ form.formtastic, form.formtastic ul, form.formtastic ol, form.formtastic li, form.formtastic fieldset, form.formtastic legend, form.formtastic input, form.formtastic textarea, form.formtastic select, form.formtastic p { margin:0; padding:0; }
16
+ form.formtastic fieldset { border:0; }
17
+ form.formtastic em, form.formtastic strong { font-style:normal; font-weight:normal; }
18
+ form.formtastic ol, form.formtastic ul { list-style:none; }
19
+ form.formtastic abbr, form.formtastic acronym { border:0; font-variant:normal; }
20
+ form.formtastic input, form.formtastic textarea, form.formtastic select { font-family:inherit; font-size:inherit; font-weight:inherit; }
21
+ form.formtastic input, form.formtastic textarea, form.formtastic select { font-size:100%; }
22
+ form.formtastic legend { color:#000; }
23
+
24
+
25
+ /* FIELDSETS & LISTS
26
+ --------------------------------------------------------------------------------------------------*/
27
+ form.formtastic fieldset { }
28
+ form.formtastic fieldset.inputs { }
29
+ form.formtastic fieldset.buttons { padding-left:25%; }
30
+ form.formtastic fieldset ol { }
31
+ form.formtastic fieldset.buttons li { float:left; padding-right:0.5em; }
32
+
33
+ /* clearfixing the fieldsets */
34
+ form.formtastic fieldset { display: inline-block; }
35
+ form.formtastic fieldset:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
36
+ html[xmlns] form.formtastic fieldset { display: block; }
37
+ * html form.formtastic fieldset { height: 1%; }
38
+
39
+
40
+ /* INPUT LIs
41
+ --------------------------------------------------------------------------------------------------*/
42
+ form.formtastic fieldset ol li { margin-bottom:1.5em; }
43
+
44
+ /* clearfixing the li's */
45
+ form.formtastic fieldset ol li { display: inline-block; }
46
+ form.formtastic fieldset ol li:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
47
+ html[xmlns] form.formtastic fieldset ol li { display: block; }
48
+ * html form.formtastic fieldset ol li { height: 1%; }
49
+
50
+ form.formtastic fieldset ol li.required { }
51
+ form.formtastic fieldset ol li.optional { }
52
+ form.formtastic fieldset ol li.error { }
53
+
54
+
55
+ /* LABELS
56
+ --------------------------------------------------------------------------------------------------*/
57
+ form.formtastic fieldset ol li label { display:block; width:25%; float:left; padding-top:.2em; }
58
+ form.formtastic fieldset ol li li label { line-height:100%; padding-top:0; }
59
+ form.formtastic fieldset ol li li label input { line-height:100%; vertical-align:middle; margin-top:-0.1em;}
60
+
61
+
62
+ /* NESTED FIELDSETS AND LEGENDS (radio, check boxes and date/time inputs use nested fieldsets)
63
+ --------------------------------------------------------------------------------------------------*/
64
+ form.formtastic fieldset ol li fieldset { position:relative; }
65
+ form.formtastic fieldset ol li fieldset legend { position:absolute; width:25%; padding-top:0.1em; }
66
+ form.formtastic fieldset ol li fieldset legend span { position:absolute; }
67
+ form.formtastic fieldset ol li fieldset ol { float:left; width:74%; margin:0; padding:0 0 0 25%; }
68
+ form.formtastic fieldset ol li fieldset ol li { padding:0; border:0; }
69
+
70
+
71
+ /* INLINE HINTS
72
+ --------------------------------------------------------------------------------------------------*/
73
+ form.formtastic fieldset ol li p.inline-hints { color:#666; margin:0.5em 0 0 25%; }
74
+
75
+
76
+ /* INLINE ERRORS
77
+ --------------------------------------------------------------------------------------------------*/
78
+ form.formtastic fieldset ol li p.inline-errors { color:#cc0000; margin:0.5em 0 0 25%; }
79
+ form.formtastic fieldset ol li ul.errors { color:#cc0000; margin:0.5em 0 0 25%; list-style:square; }
80
+ form.formtastic fieldset ol li ul.errors li { padding:0; border:none; display:list-item; }
81
+
82
+
83
+ /* STRING & NUMERIC OVERRIDES
84
+ --------------------------------------------------------------------------------------------------*/
85
+ form.formtastic fieldset ol li.string input { width:74%; }
86
+ form.formtastic fieldset ol li.numeric input { width:74%; }
87
+
88
+
89
+ /* TEXTAREA OVERRIDES
90
+ --------------------------------------------------------------------------------------------------*/
91
+ form.formtastic fieldset ol li.text textarea { width:74%; }
92
+
93
+
94
+ /* HIDDEN OVERRIDES
95
+ --------------------------------------------------------------------------------------------------*/
96
+ form.formtastic fieldset ol li.hidden { display:none; }
97
+
98
+
99
+ /* BOOLEAN OVERRIDES
100
+ --------------------------------------------------------------------------------------------------*/
101
+ form.formtastic fieldset ol li.boolean label { padding-left:25%; width:auto; }
102
+ form.formtastic fieldset ol li.boolean label input { margin:0 0.5em 0 0.2em; }
103
+
104
+
105
+ /* RADIO OVERRIDES
106
+ --------------------------------------------------------------------------------------------------*/
107
+ form.formtastic fieldset ol li.radio { }
108
+ form.formtastic fieldset ol li.radio fieldset ol { margin-bottom:-0.6em; }
109
+ form.formtastic fieldset ol li.radio fieldset ol li { margin:0.1em 0 0.5em 0; }
110
+ form.formtastic fieldset ol li.radio fieldset ol li label { float:none; width:100%; }
111
+ form.formtastic fieldset ol li.radio fieldset ol li label input { margin-right:0.2em; }
112
+
113
+
114
+ /* CHECK BOXES (COLLECTION) OVERRIDES
115
+ --------------------------------------------------------------------------------------------------*/
116
+ form.formtastic fieldset ol li.check_boxes { }
117
+ form.formtastic fieldset ol li.check_boxes fieldset ol { margin-bottom:-0.6em; }
118
+ form.formtastic fieldset ol li.check_boxes fieldset ol li { margin:0.1em 0 0.5em 0; }
119
+ form.formtastic fieldset ol li.check_boxes fieldset ol li label { float:none; width:100%; }
120
+ form.formtastic fieldset ol li.check_boxes fieldset ol li label input { margin-right:0.2em; }
121
+
122
+
123
+
124
+ /* DATE & TIME OVERRIDES
125
+ --------------------------------------------------------------------------------------------------*/
126
+ form.formtastic fieldset ol li.date fieldset ol li,
127
+ form.formtastic fieldset ol li.time fieldset ol li,
128
+ form.formtastic fieldset ol li.datetime fieldset ol li { float:left; width:auto; margin:0 .3em 0 0; }
129
+
130
+ form.formtastic fieldset ol li.date fieldset ol li label,
131
+ form.formtastic fieldset ol li.time fieldset ol li label,
132
+ form.formtastic fieldset ol li.datetime fieldset ol li label { display:none; }
133
+
134
+ form.formtastic fieldset ol li.date fieldset ol li label input,
135
+ form.formtastic fieldset ol li.time fieldset ol li label input,
136
+ form.formtastic fieldset ol li.datetime fieldset ol li label input { display:inline; margin:0; padding:0; }
@@ -0,0 +1,10 @@
1
+ /* -------------------------------------------------------------------------------------------------
2
+
3
+ Load this stylesheet after formtastic.css in your layouts to override the CSS to suit your needs.
4
+ This will allow you to update formtastic.css with new releases without clobbering your own changes.
5
+
6
+ For example, to make the inline hint paragraphs a little darker in color than the standard #666:
7
+
8
+ form.formtastic fieldset ol li p.inline-hints { color:#333; }
9
+
10
+ --------------------------------------------------------------------------------------------------*/