Permalink
Browse files

Merge branch 'master' into sexy_specs

  • Loading branch information...
2 parents 0426eb6 + f72a6f3 commit e7426a982aa44af0e1bd87f9f160bfb2fe59420a @haines haines committed Jan 16, 2012
View
@@ -4,6 +4,7 @@ coverage
coverage.data
pkg
*~
+*.swp
*watchr.rb
log/*
.rvmrc
View
@@ -7,5 +7,5 @@ appraise 'rails-3.1' do
end
appraise 'rails-3.2' do
- gem 'rails', '~> 3.2.0.rc1'
+ gem 'rails', '~> 3.2.0.rc2'
end
View
@@ -40,8 +40,9 @@ One day, I finally had enough, so I opened up my text editor, and wrote a DSL fo
<%= author_form.input :last_name %>
<% end %>
- <%= f.buttons do %>
- <%= f.commit_button %>
+ <%= f.actions do %>
+ <%= f.action :submit, :as => :button %>
+ <%= f.action :cancel, :as => :link %>
<% end %>
<% end %>
@@ -139,27 +140,27 @@ h2. Usage
Forms are really boring to code... you want to get onto the good stuff as fast as possible.
-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:
+This renders a set of inputs (one for _most_ columns in the database table, and one for each ActiveRecord @belongs_to@-association), followed by default action buttons (an input submit button):
<pre>
<%= semantic_form_for @user do |f| %>
<%= f.inputs %>
- <%= f.buttons %>
+ <%= f.actions %>
<% end %>
</pre>
This is a great way to get something up fast, but like scaffolding, it's *not recommended for production*. Don't be so lazy!
-To specify the order of the fields, skip some of the fields or even add in fields that Formtastic couldn't infer. You can pass in a list of field names to @inputs@ and list of button names to @buttons@:
+To specify the order of the fields, skip some of the fields or even add in fields that Formtastic couldn't infer. You can pass in a list of field names to @inputs@ and list of action names to @actions@:
<pre>
<%= semantic_form_for @user do |f| %>
<%= f.inputs :title, :body, :section, :categories, :created_at %>
- <%= f.buttons :commit %>
+ <%= f.actions :submit, :cancel %>
<% end %>
</pre>
-You probably want control over the input type Formtastic uses for each field. You can expand the @inputs@ and @buttons@ to block helper format and use the @:as@ option to specify an exact input type:
+You probably want control over the input type Formtastic uses for each field. You can expand the @inputs@ and @actions@ to block helper format and use the @:as@ option to specify an exact input type:
<pre>
<%= semantic_form_for @post do |f| %>
@@ -170,8 +171,9 @@ You probably want control over the input type Formtastic uses for each field. Yo
<%= f.input :categories %>
<%= f.input :created_at, :as => :string %>
<% end %>
- <%= f.buttons do %>
- <%= f.commit_button %>
+ <%= f.actions do %>
+ <%= f.action :submit, :as => :button %>
+ <%= f.action :cancel, :as => :link %>
<% end %>
<% end %>
</pre>
@@ -191,8 +193,8 @@ If you want to customize the label text, or render some hint text below the fiel
<%= f.input :categories, :required => false %>
<%= f.input :created_at, :as => :string, :label => "Publication Date", :required => false %>
<% end %>
- <%= f.buttons do %>
- <%= f.commit_button %>
+ <%= f.actions do %>
+ <%= f.action :submit %>
<% end %>
<% end %>
</pre>
@@ -211,7 +213,7 @@ Nested forms are also supported (don't forget your models need to be setup corre
<%= f.semantic_fields_for :author do |author| %>
<%= author.inputs :first_name, :last_name, :name => "Author" %>
<% end %>
- <%= f.buttons %>
+ <%= f.actions %>
<% end %>
</pre>
@@ -221,7 +223,7 @@ Or the Formtastic way with the @:for@ option:
<%= semantic_form_for @post do |f| %>
<%= f.inputs :title, :body, :created_at %>
<%= f.inputs :first_name, :last_name, :for => :author, :name => "Author" %>
- <%= f.buttons %>
+ <%= f.actions %>
<% end %>
</pre>
@@ -231,7 +233,7 @@ When working in has many association, you can even supply @"%i"@ in your fieldse
<%= semantic_form_for @post do |f| %>
<%= f.inputs %>
<%= f.inputs :name => 'Category #%i', :for => :categories %>
- <%= f.buttons %>
+ <%= f.actions %>
<% end %>
</pre>
@@ -244,7 +246,7 @@ If you have more than one form on the same page, it may lead to HTML invalidatio
<%= f.input :body %> # id="cat_form_post_body"
<%= f.input :created_at %> # id="cat_form_post_created_at"
<% end %>
- <%= f.buttons %>
+ <%= f.actions %>
<% end %>
</pre>
@@ -256,18 +258,19 @@ Customize HTML attributes for any input using the @:input_html@ option. Typicall
<%= f.input :title, :input_html => { :size => 10 } %>
<%= f.input :body, :input_html => { :class => 'autogrow', :rows => 10, :cols => 20, :maxlength => 10 } %>
<%= f.input :created_at, :input_html => { :disabled => true } %>
+ <%= f.input :updated_at, :input_html => { :readonly => true } %>
<% end %>
- <%= f.buttons %>
+ <%= f.actions %>
<% end %>
</pre>
-The same can be done for buttons with the @:button_html@ option:
+The same can be done for actions with the @:button_html@ option:
<pre>
<%= semantic_form_for @post do |f| %>
...
- <%= f.buttons do %>
- <%= f.commit_button :button_html => { :class => "primary", :disable_with => 'Wait...' } %>
+ <%= f.actions do %>
+ <%= f.action :submit, :button_html => { :class => "primary", :disable_with => 'Wait...' } %>
<% end %>
<% end %>
</pre>
@@ -408,6 +411,8 @@ Formtastic supports localized *labels*, *hints*, *legends*, *actions* using the
actions:
create: "Create my %{model}"
update: "Save changes"
+ reset: "Reset form"
+ cancel: "Cancel and go back"
dummie: "Launch!"
</pre>
@@ -420,8 +425,8 @@ Formtastic supports localized *labels*, *hints*, *legends*, *actions* using the
<%= f.input :body %> # => :label => "Write something...", :hint => "Write something inspiring here."
<%= f.input :section %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
<% end %>
- <%= f.buttons do %>
- <%= f.commit_button %> # => "Create my %{model}"
+ <%= f.actions do %>
+ <%= f.action :submit %> # => "Create my %{model}"
<% end %>
<% end %>
</pre>
@@ -448,8 +453,8 @@ _Note: Slightly different because Formtastic can't guess how you group fields in
<%= f.input :body, :hint => false %> # => :label => "Write something..."
<%= f.input :section, :label => 'Some section' %> # => :label => 'Some section'
<% end %>
- <%= f.buttons do %>
- <%= f.commit_button :dummie %> # => "Launch!"
+ <%= f.actions do %>
+ <%= f.action :submit, :label => :dummie %> # => "Launch!"
<% end %>
<% end %>
</pre>
@@ -469,8 +474,8 @@ If I18n-lookups is disabled, i.e.:
<%= f.input :body, :label => true %> # => :label => "Write something..."
<%= f.input :section, :label => true %> # => :label => I18n.t('activerecord.attributes.user.section') or 'Section'
<% end %>
- <%= f.buttons do %>
- <%= f.commit_button true %> # => "Update %{model}" (if we are in edit that is...)
+ <%= f.actions do %>
+ <%= f.action :submit, :label => true %> # => "Update %{model}" (if we are in edit that is...)
<% end %>
<% end %>
</pre>
@@ -597,27 +602,25 @@ There are none, but...
h2. How to contribute
-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 a pull request for your changes to be discussed and reviewed.
+* Fork the project on Github
+* Create a topic branch for your changes
+* Ensure that all tests pass (`bundle exec rake`)
+* Ensure that the changes in your branch are as atomic as possible
+* Create a pull request on Github
-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.
-
-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.
-
-See below for installation of a development environment.
+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.
h2. Google Group, Twitter, etc
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.
-You can also "follow @formtastic on Twitter":http://twitter.com/formtastic for announcements, tutorials and awesome Formtastic links.
+You can also follow "@justinfrench":http://twitter.com/formtastic or "@formtastic":http://twitter.com/formtastic on Twitter for announcements, tutorials and links.
h2. Project Info
-Formtastic was created by "Justin French":http://www.justinfrench.com with contributions from over 100 awesome developers.
-
-Run @git shortlog -n -s@ to see the awesome.
+Formtastic was created by "Justin French":http://www.justinfrench.com with contributions from around 150 awesome developers. Run @git shortlog -n -s@ to see the awesome.
The project is hosted on Github: "http://github.com/justinfrench/formtastic":http://github.com/justinfrench/formtastic, where your contributions, forkings, comments, issues and feedback are greatly welcomed.
-Copyright (c) 2007-2010 Justin French, released under the MIT license.
+Copyright (c) 2007-2012 Justin French, released under the MIT license.
@@ -18,6 +18,7 @@ This stylesheet forms part of the Formtastic Rails Plugin
.formtastic fieldset,
.formtastic legend,
.formtastic input,
+.formtastic button,
.formtastic textarea,
.formtastic select,
.formtastic p {
@@ -47,6 +48,7 @@ This stylesheet forms part of the Formtastic Rails Plugin
}
.formtastic input,
+.formtastic button,
.formtastic textarea {
font-family:sans-serif;
font-size:inherit;
@@ -80,18 +82,29 @@ This stylesheet forms part of the Formtastic Rails Plugin
}
-/* BUTTONS
+/* BUTTONS & ACTIONS
--------------------------------------------------------------------------------------------------*/
-.formtastic .buttons {
+.formtastic .buttons,
+.formtastic .actions {
overflow:hidden; /* clear containing floats */
padding-left:25%;
}
-.formtastic .button {
+.formtastic .button,
+.formtastic .action {
float:left;
padding-right:0.5em;
}
+.formtastic .button_action button {
+ padding:3px 8px;
+}
+
+.formtastic .link_action a {
+ display:block;
+ padding:3px 0;
+}
+
/* INPUTS
--------------------------------------------------------------------------------------------------*/
View
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<actionpack>, ["~> 3.0"])
- s.add_development_dependency(%q<rspec-rails>, ["~> 2.8.0.rc2"])
+ s.add_development_dependency(%q<rspec-rails>, ["~> 2.8.0"])
s.add_development_dependency(%q<rspec_tag_matchers>, [">= 1.0.0"])
s.add_development_dependency(%q<hpricot>, ["~> 0.8.3"])
s.add_development_dependency(%q<BlueCloth>) # for YARD
@@ -2,6 +2,6 @@
source :rubygems
-gem "rails", "~> 3.2.0.rc1"
+gem "rails", "~> 3.2.0.rc2"
gemspec :path=>"../"
View
@@ -9,6 +9,7 @@ module Formtastic
autoload :HtmlAttributes
autoload :I18n
autoload :Inputs
+ autoload :Actions
autoload :LocalizedString
autoload :Localizer
autoload :Util
@@ -17,8 +18,16 @@ module Formtastic
class UnknownInputError < NameError
end
+ # @private
+ class UnknownActionError < NameError
+ end
+
# @private
class PolymorphicInputWithoutCollectionError < ArgumentError
end
+ # @private
+ class UnsupportedMethodForAction < ArgumentError
+ end
+
end
View
@@ -0,0 +1,11 @@
+module Formtastic
+ module Actions
+ extend ActiveSupport::Autoload
+
+ autoload :Base
+ autoload :Buttonish
+ autoload :InputAction
+ autoload :LinkAction
+ autoload :ButtonAction
+ end
+end
Oops, something went wrong.

0 comments on commit e7426a9

Please sign in to comment.