This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
David Rice (author)
Fri Apr 18 18:11:27 -0700 2008
| name | age | message | |
|---|---|---|---|
| |
README | Fri Apr 18 18:11:27 -0700 2008 | [David Rice] |
| |
Rakefile | Fri Apr 18 18:11:27 -0700 2008 | [David Rice] |
| |
init.rb | Fri Apr 18 18:11:27 -0700 2008 | [David Rice] |
| |
install.rb | Fri Apr 18 18:11:27 -0700 2008 | [David Rice] |
| |
lib/ | Fri Apr 18 18:11:27 -0700 2008 | [David Rice] |
| |
tasks/ | Fri Apr 18 18:11:27 -0700 2008 | [David Rice] |
| |
uninstall.rb | Fri Apr 18 18:11:27 -0700 2008 | [David Rice] |
README
AjaxValidation
==============
This is a basic extension to provide inline AJAX powered validation of your models it is currently
a very early version so there are a number of assumptions.
* It assumes that your model/controller are singular/plural post/posts
* It assumes you are using the form_for helper
Example
--------------
In routes.rb add the following, this extra action allows us to validate the model
map.resources :posts, :collection => [:validate]
In your controller add the following
class PostsController < ApplicationController
ajax_validation_for :post
...
end
Lets take a look at an example view, the new.rhtml. As you can see we are using a custom form builder
ajax_validation_form_for, this will generate some html around the form elements. A number of elements will have
to be defined manually however, their html should looks something like the user_id field. Note the id specified
in the form_for, is referenced in the call to observe_form.
If ordered list forms aren't your taste, it's not to hard to override the form builder to produce something different.
There is an example css file that will help as a starter.
<h1>New Post</h1>
<%= error_messages_for :post %>
<%- ajax_validation_form_for(:post, :url => posts_url, :html => {:id => "post_form"}) do |f| -%>
<%= f.text_field :title %>
<%= f.text_area :body %>
<li id="post_user_id_item">
<label for="post_user_id">Author<span class="hint"></span></label>
<%= f.collection_select :user_id, @users, :id, :display_name %>
<span id="post_user_id_validation"></span>
</li>
<%= f.datetime_select :published_at %>
<%= f.date_select :expires_on %>
<%= f.check_box :live %>
<%= submit_tag "Create" %>
<%- end -%>
<%= observe_form :post_form, :url => validate_posts_path, :frequency => 2 %>



