Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

form_for outside of ActionView

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 features
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 README.md
Octocat-spinner-32 semi-formal.gemspec
README.md

semi-formal

Sort of like form_for, but a bit less formal.

Usage (not ready yet...)

First, include SemiFormal:

include SemiFormal

Then pass form_for an instance of an ActiveRecord model:

form_for(Article.new)

By default, the model's value columns will have fields generated for them in a form.

If you want a more custom form than that, you can pass a block:

form_for(Article.new) do |builder|
  label do
    span "Title:"
    builder.text_field(:title)
  end

  label do
    span "Body:"
    builder.text_area(:body)
  end

  input :type => "submit", :value => "Save!"
end

In the block, you can use all of the helpers you get from Nokogiri's builder, plus you have access to the block arg which will behave like it does in Rails.

TODO

  • Only generate fields for columns that are attr_accessible
  • Allow an :include option for associations or something

(c) Copyright 2008 Pat Nakajima, released under MIT License.

Something went wrong with that request. Please try again.