Skip to content

Instantly share code, notes, and snippets.

@mhenrixon
Created April 17, 2011 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhenrixon/923838 to your computer and use it in GitHub Desktop.
Save mhenrixon/923838 to your computer and use it in GitHub Desktop.
require 'client_side_validations/simple_form' if defined?(::SimpleForm)
require 'client_side_validations/formtastic' if defined?(::Formtastic)
# Uncomment the following block if you want each input field to have the validation messages attached.
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
unless html_tag =~ /^<label/
%{<div class="field_with_errors">#{html_tag}<label for="#{instance.send(:tag_id)}" class="message">#{instance.error_message.first}</label></div>}.html_safe
else
%{<div class="field_with_errors">#{html_tag}</div>}.html_safe
end
end
# encoding: utf-8
Formtastic::SemanticFormBuilder.inline_order = [:input]
Formtastic::SemanticFormBuilder.custom_inline_order[:checkbox] = [:input]
Formtastic::SemanticFormBuilder.custom_inline_order[:select] = [:input]
<li class="string optional error" id="account_delivery_address_attributes_zip_input">
<label for="account_delivery_address_attributes_zip">Zip</label>
<input data-validate="true" id="account_delivery_address_attributes_zip"
maxlength="10" name="account[delivery_address_attributes][zip]"
size="30" type="text">
<p class="inline-errors">can't be blank</p>
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment