Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

Commit

Permalink
Add hints. Clean up tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Bellantoni committed Nov 8, 2011
1 parent 9998cdb commit ff950a3
Show file tree
Hide file tree
Showing 6 changed files with 991 additions and 5 deletions.
24 changes: 24 additions & 0 deletions lib/formtastic-bootstrap/form_builder.rb
Expand Up @@ -4,6 +4,30 @@ class FormBuilder < Formtastic::FormBuilder

configure :default_inline_error_class, 'help-inline'
configure :default_block_error_class, 'help-block'
configure :default_inline_hint_class, 'help-inline'
configure :default_block_hint_class, 'help-block'

def self.default_error_class
# self.default_inline_error_class
raise
end

def self.default_error_class=(error_class)
# self.default_inline_error_class = error_class
# self.default_block_error_class = error_class
raise
end

def self.default_hint_class
# self.default_inline_hint_class
raise
end

def self.default_hint_class=(hint_class)
# self.default_inline_hint_class = hint_class
# self.default_block_hint_class = hint_class
raise
end

include FormtasticBootstrap::Helpers::InputHelper
include FormtasticBootstrap::Helpers::InputsHelper
Expand Down
2 changes: 1 addition & 1 deletion lib/formtastic-bootstrap/inputs/base.rb
Expand Up @@ -11,8 +11,8 @@ module FormtasticBootstrap
module Inputs
module Base

# include Hints
include Errors
include Hints
include Html
include Labelling
include Wrapping
Expand Down
2 changes: 1 addition & 1 deletion lib/formtastic-bootstrap/inputs/base/choices.rb
Expand Up @@ -5,7 +5,7 @@ module Choices

def input_div_wrapping(&block)
template.content_tag(:div, choices_wrapping_html_options) do
[yield, error_html(:block), hint_html].join("\n").html_safe
[yield, error_html(:block), hint_html(:block)].join("\n").html_safe
end
end

Expand Down
10 changes: 8 additions & 2 deletions lib/formtastic-bootstrap/inputs/base/hints.rb
Expand Up @@ -5,12 +5,17 @@ module Hints

include Formtastic::Inputs::Base::Hints

def hint_html
def hint_html(inline_or_block = :inline)
if hint?
hint_class = if inline_or_block == :inline
options[:hint_class] || builder.default_inline_hint_class
else
options[:hint_class] || builder.default_block_hint_class
end
template.content_tag(
:span,
Formtastic::Util.html_safe(hint_text),
:class => (options[:hint_class] || builder.default_hint_class)
:class => hint_class
)
end
end
Expand All @@ -19,3 +24,4 @@ def hint_html
end
end
end

2 changes: 1 addition & 1 deletion lib/formtastic-bootstrap/inputs/base/wrapping.rb
Expand Up @@ -22,7 +22,7 @@ def clearfix_div_wrapping(&block)

def input_div_wrapping(inline_or_block_errors = :inline)
template.content_tag(:div, :class => "input") do
[yield, error_html(inline_or_block_errors), hint_html].join("\n").html_safe
[yield, error_html(inline_or_block_errors), hint_html(inline_or_block_errors)].join("\n").html_safe
end
end

Expand Down

0 comments on commit ff950a3

Please sign in to comment.