Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An input plugin for formtastic to render belongs_to_enum fields
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
tasks
MIT-LICENSE
README.textile
Rakefile
init.rb

README.textile

FormtasticEnum

An extension for Formtastic1 to generate select inputs for belongs_to_enum2 fields.

Example

In the model class:

class Task < ActiveRecord::Base
  belongs_to_enum :status, { 1 => :new, 2 => :in_progress, 3 => :completed, 4 => :cancelled }
end

And in the view

<% semantic_form_for @task do |form| %>
  <% form.inputs do %>
    <%= form.input :status, :as => :enum %>
  <% end %>
<% end %>

Dependencies

You must have the formtastic gem/plugin and the belongs_to_enum plugin added to your application.

Todo

Test, test, test…

References

1 Formtastic @ GitHub

2 BelongsToEnum @ Github

Copyright © 2009 Paul Smith, released under the MIT license

Something went wrong with that request. Please try again.