Skip to content
Browse files

removed ajax helpers, using lowpro now, and fixed some bugs regarding…

… error validations
  • Loading branch information...
1 parent b9f5a20 commit bbc5784f49ab6f2f968f7c72e56a666b1ed4bf0f @nesquena committed May 18, 2008
Showing with 4 additions and 27 deletions.
  1. BIN .DS_Store
  2. +3 −3 lib/semantic_fields_renderer.rb
  3. +1 −1 lib/semantic_form_builder.rb
  4. +0 −23 lib/semantic_form_helpers.rb
View
BIN .DS_Store
Binary file not shown.
View
6 lib/semantic_fields_renderer.rb
@@ -82,7 +82,7 @@ def submit_tag(label, options={})
#
# ex. f.text_field_tag :login, :label => "Login"
#
- # options hash can have { :id => "field id", :label => "field label", :value => "field value" ]
+ # options hash can have { :id => "field id", :label => "field label", :value => "field value", :error => true ]
#
def self.create_field_element(input_type)
field_tag_name = "#{input_type}_tag" # i.e text_field_tag
@@ -96,9 +96,9 @@ def self.create_field_element(input_type)
end
html << content_tag(:dd) do
- @super.send(field_tag_name, name, options.delete(:value), options)
+ html_tag = @super.send(field_tag_name, name, options.delete(:value), options)
+ options.delete(:error) ? ActionView::Base.field_error_proc.call(html_tag, @object) : html_tag
end
-
end
end
View
2 lib/semantic_form_builder.rb
@@ -197,7 +197,7 @@ def self.create_field_element(input_type_name)
raise "Semantic form fields must be contained within a fieldset!" unless @renderer
options = args.length > 0 ? args[0] : {} # grab the options hash
object_value = @object ? @object.send(attribute) : nil # grab the object's value
- options.reverse_merge!(:label => attribute.to_s.titleize, :id => "#{object_name(:id)}_#{attribute}", :value => object_value)
+ options.reverse_merge!(:label => attribute.to_s.titleize, :id => "#{object_name(:id)}_#{attribute}", :value => object_value, :error => @object.errors.on(attribute))
@renderer.send(template_method, "#{object_name}[#{attribute}]", options)
end
end
View
23 lib/semantic_form_helpers.rb
@@ -73,29 +73,6 @@ def semantic_fields_for(name, *args, &block)
use_semantic_builder(:fields_for, name, *args, &block)
end
- # creates a ajaxy form based on a model's data using the standard builder
- # an ajaxy form is a form which automatically hides the submit button
- # and then shows an ajax loader when the submit button is clicked
- #
- # to make it work, the ajaxy form must have a special submit that is
- # created by using the 'submit_with_ajax' helper
- #
- # ex:
- #
- # - semantic_ajaxy_form_for :user, :url => create_user_url do |s|
- # - s.fieldset do |f|
- # = f.text_field :login
- # = submit_with_ajax_tag "Create"
- #
- def semantic_ajaxy_form_for(name, *args, &block)
- options = args.last.is_a?(Hash) ? args.pop : {}
- element_id = options[:html][:id] if options[:html]
- raise "Ajax form needs an identifying html id to be specified!" unless element_id
- options = options.reverse_merge!(:before => "ajaxyFormBefore('#{element_id}')", :complete => "ajaxyFormComplete('#{element_id}')")
- args = (args << options)
- use_semantic_builder(:remote_form_for, name, *args, &block)
- end
-
# Creates a fieldset around the content block
#
# <fieldset>

0 comments on commit bbc5784

Please sign in to comment.
Something went wrong with that request. Please try again.