Skip to content
Customized form help builder
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
generators
lib
tasks
test
MIT-LICENSE
README
Rakefile
init.rb
install.rb
uninstall.rb

README

JsFormBuilder
=============

Keep it simple :)

I included validation_reflection plugin inside my plugin.
http://rubyforge.org/projects/valirefl/validation_reflection/trunk





Example
=======

Rails => 
<% js_form_for :user, @user, :align => "vertical" do |f| %>
	<%= f.text_field :email %>
	<%= f.text_field :name %>
	<%= f.password_field :password %>
	<%= f.submit_or_cancel %>
<% end %>

HTML => 
<form action="/" class="vertical" method="post">
  <div class="row required">
    <div class="label">
      <label for="user_email">Email</label>
      <em>required</em></div>
    <div class="input">
      <div class="text_field">
        <input id="user_email" name="user[email]" size="30" type="text" />
      </div>
    </div>
  </div>
  <div class="row required">
    <div class="label">
      <label for="user_name">Navn</label>
      <em>required</em></div>
    <div class="input">
      <div class="text_field">
        <input id="user_name" name="user[name]" size="30" type="text" />
      </div>
    </div>
  </div>
  <div class="row required">
    <div class="label">
      <label for="user_password">Adgangskode</label>
      <em>required</em></div>
    <div class="input">
      <div class="password_field">
        <input id="user_password" name="user[password]" size="30" type="password" />
      </div>
    </div>
  </div>
  <div class="submit">
    <div class="submit_or_cancel">
      <input id="user_submit" name="commit" type="submit" value="Save changes" />
      or <a href="/">Cancel</a></div>
  </div>
</form>





Translation
===========

The form builder handles translation as follows.

1. It checks if :label option is not nil.
f.text_field :name, :label => "Name"

2. Then it tries to find the locale translation.
Class.human_attribute_name(:name)

3. Last it just converts :name to string





Install
=======

You need to install the plugin:
ruby script/plugin install git://github.com/jamalsoueidan/js_formbuilder.git


Then if you want to, you can auto-generate the form.css file by:
ruby script/generate js_formbuilder

Now the form.css is available for you.

<%= stylesheet_link_tag "form" %>

That's it :)

Copyright (c) 2009 Jamal Soueidan, released under the MIT license
Something went wrong with that request. Please try again.