Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: justinfrench/formtastic
...
head fork: rgarner/formtastic
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 10, 2010
@justinfrench resolves GH-365 by adding top and bottom padding to the li, then taki…
…ng it away with a negative margin (top) and reduced margin (bottom)
e73be1d
Commits on Sep 13, 2010
@justinfrench README installation instructions simlified and clarified to specific …
…that Bundler is required, even under Rails 2
2c6e15a
Commits on Sep 17, 2010
@justinfrench reduce the max-width of string/numeric inputs and the width of textar…
…eas by 2% to avoid issues with overflow:auto; in Firefox. Quick fix for now to (re-)address GH-365
510d31d
@justinfrench remove the em width on password inputs, replace with a percentage whi…
…ch is conistent with other inputs -- designers can override in their own styles if needed, resolves GH-367
c67cc05
Commits on Sep 21, 2010
@justinfrench updated the generator docs in README to reflect both Rails 3 and 2 7a11c71
Showing with 56 additions and 67 deletions.
  1. +51 −62 README.textile
  2. +5 −5 generators/formtastic/templates/formtastic.css
View
113 README.textile
@@ -77,50 +77,30 @@ h2. Documentation
RDoc documentation _should_ be automatically generated after each commit and made available on the "rdoc.info website":http://rdoc.info/projects/justinfrench/formtastic.
-h2. A Note About Rails 3 Support
+h2. Installation
-Formtastic 1.0 only supports the latest stable Rails 2.x. We're maintaining a rails3 branch which aims to provide both Rails 2.x and 3.x support, which is targeted for the 1.1 release around the same time Rails 3.0 final ships.
+Formtastic is now compatible with both Rails 2 and Rails 3, and the gem is "hosted":http://rubygems.org/gems/formtastic on RubyGems.org.
-A 1.1.0 gem is now available on RubyGems.org:
-
-<pre>
- gem install formtastic
-</pre>
-
-Or bundle it in your Gemfile:
-
-<pre>
- gem 'formtastic', '1.1.0'
-</pre>
-
-You can also live on the edge and track our rails3 branch in your Gemfile with the :git and :branch options:
-
-<pre>
- gem 'formtastic', :git => "git://github.com/justinfrench/formtastic.git", :branch => "rails3"
-</pre>
-
-Please be aware that Rails 3 is still under heavy development (even in the RCs), as is Formtastic, so our beta gems and the rails3 branch is very much "on the edge", just like Rails. If you find compatibility issues with Rails 2 or 3, please report them on Github.
+*You'll need to use Bundler (yes, even under Rails 2, due to the many ways gem dependencies suck). Follow "this tutorial":http://gembundler.com/rails23.html.*
-
-h2. Installation under Rails 2.x
-
-Install the Formtastic gem:
+Simply add Formtastic to your Gemfile and bundle it up:
<pre>
- sudo gem install formtastic
+ gem 'formtastic', '~> 1.1.0'
</pre>
-And add it to your environment.rb configuration as a gem dependency:
+Optionally, run the generator to copy some stylesheets and a configuration initializer into your application:
<pre>
- config.gem 'formtastic'
+ # Rails 3:
+ $ rails generate formtastic:install
+
+ # Or Rails 2:
+ $ ./script/generate formtastic
</pre>
-Optionally, run @./script/generate formtastic@ to copy the following files into your app:
-* @config/initializers/formtastic.rb@ - a commented out Formtastic config initializer
-* @public/stylesheets/formtastic.css@
-* @public/stylesheets/formtastic_changes.css@
+h2. Stylesheets
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:
@@ -481,51 +461,67 @@ If you have the "ValidationReflection":http://github.com/redinger/validation_ref
h2. Configuration
-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
+Run @rails generate formtastic:install@ (Rails 3) or @./script/generate formtastic@ (Rails 2) 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
h2. Form Generator
-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:
+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 your stuff.
-*Alt. 1: Generate in terminal:*
+h3. Basic usage
+
+Rails 3:
<pre>
-$ ./script/generate form Post
-# ---------------------------------------------------------
-# GENERATED FORMTASTIC CODE
-# ---------------------------------------------------------
+ $ rails generate formtastic:form ModelName
+</pre>
-<% f.inputs do %>
- <%= f.input :title, :label => 'Title' %>
- <%= f.input :body, :label => 'Body' %>
- <%= f.input :published, :label => 'Published' %>
-<% end %>
+Rails 2:
-# ---------------------------------------------------------
- Copied to clipboard - just paste it!
+<pre>
+ $ ./script/generate form ModelName
</pre>
-*Alt. 2: Generate partial:*
+The results are something like this, with the ERB code printed out to the terminal
<pre>
-$ ./script/generate form Post --partial
+ $ rails generate formtastic:form Post
+ # ---------------------------------------------------------
+ # GENERATED FORMTASTIC CODE
+ # ---------------------------------------------------------
+
+ <% f.inputs do %>
+ <%= f.input :title, :label => 'Title' %>
+ <%= f.input :body, :label => 'Body' %>
+ <%= f.input :published, :label => 'Published' %>
+ <% end %>
+
+ # ---------------------------------------------------------
+ Copied to clipboard - just paste it!
+</pre>
+
+h3. Generating a partial with @--partial@
+
+You can also ask Formtastic to *generate a partial* with the @--partial@ option, placing it in the correct location inside your @app/views@ directory:
+
+<pre>
+ $ rails generate formastic:form Post --partial
exists app/views/posts
create app/views/posts/_form.html.erb
</pre>
-To generate *HAML* markup, just add the @--haml@ as argument:
+h3. Specifying HAML instead of ERB with @--haml@
<pre>
-$ ./script/generate form Post --haml
+ $ rails generate formastic:form Post --haml
exists app/views/admin/posts
create app/views/admin/posts/_form.html.haml
</pre>
-To specify the controller in a namespace (eg admin/posts instead of posts), use the --controller argument:
+h3. Specifying controller namespace with @--controller@
<pre>
-$ ./script/generate form Post --partial --controller admin/posts
+ $ rails generate formastic:form Post --partial --controller admin/posts
exists app/views/admin/posts
create app/views/admin/posts/_form.html.erb
</pre>
@@ -537,6 +533,7 @@ If you want to add your own input types to encapsulate your own logic or interfa
@Formtastic::SemanticFormHelper.builder = MyCustomBuilder@
+
h2. Security
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:
@@ -544,13 +541,6 @@ By default formtastic escapes html entities in both labels and hints unless a st
Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = false
-h2. Focus
-
-Formtastic 1.0 is compatible with Rails 2.x *only*. We've also been working hard on a Rails 2 *and* 3 compatible version in the rails3 branch, targeting a 1.1 release shortly after Rails 3.0 final ships.
-
-There's heaps more we want to do, but we have to do this first.
-
-
h2. Dependencies
There are none, but...
@@ -562,8 +552,7 @@ There are none, but...
h2. Compatibility
-* We're only testing Formtastic with the latest Rails 2.x stable release. Patches are welcome to allow backwards compatibility with older versions of Rails, of course.
-* Development of a Rails 2 *and* 3 compatible version of Formtastic is underway in the rails3 branch, targeting a Formtastic 1.1 release shortly after Rails 3.0 ships.
+* 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.
* 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.
@@ -593,4 +582,4 @@ h2. Project Info
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.
-Copyright (c) 2007-2008 Justin French, released under the MIT license.
+Copyright (c) 2007-2010 Justin French, released under the MIT license.
View
10 generators/formtastic/templates/formtastic.css
@@ -38,7 +38,7 @@ form.formtastic fieldset.buttons li { float:left; padding-right:0.5em; }
/* INPUT LIs
--------------------------------------------------------------------------------------------------*/
-form.formtastic fieldset > ol > li { margin-bottom:1.5em; }
+form.formtastic fieldset > ol > li { padding:0.5em 0; margin-top:-0.5em; margin-bottom:1em; } /* padding and negative margin juggling is for Firefox */
form.formtastic fieldset > ol > li { overflow:auto; } /* clearing contained floats */
form.formtastic fieldset > ol > li.required { }
@@ -77,14 +77,14 @@ form.formtastic fieldset > ol > li ul.errors li { padding:0; border:none; displa
/* STRING & NUMERIC OVERRIDES
--------------------------------------------------------------------------------------------------*/
-form.formtastic fieldset > ol > li.string input { max-width:74%; }
-form.formtastic fieldset > ol > li.password input { max-width: 13em; }
-form.formtastic fieldset > ol > li.numeric input { max-width:74%; }
+form.formtastic fieldset > ol > li.string input,
+form.formtastic fieldset > ol > li.password input,
+form.formtastic fieldset > ol > li.numeric input { max-width:72%; }
/* TEXTAREA OVERRIDES
--------------------------------------------------------------------------------------------------*/
-form.formtastic fieldset > ol > li.text textarea { width:74%; }
+form.formtastic fieldset > ol > li.text textarea { width:72%; }
/* HIDDEN OVERRIDES

No commit comments for this range

Something went wrong with that request. Please try again.