From 82f9f750324656f0488cc55678b0530943d24344 Mon Sep 17 00:00:00 2001 From: Marcelo Giorgi Date: Wed, 24 Jun 2009 23:30:47 -0300 Subject: [PATCH] #404 New module Hobo::Model::ViewHintExtensions to check ViewHints field_names for error validations. And changed Hobo::HoboHelper#this_field_name to use the new ViewHintExtensions module --- hobo/lib/hobo/hobo_helper.rb | 2 +- hobo/lib/hobo/model.rb | 6 +----- hobo/lib/hobo/model/view_hint_extensions.rb | 16 ++++++++++++++++ hobo/taglibs/rapid_forms.dryml | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 hobo/lib/hobo/model/view_hint_extensions.rb diff --git a/hobo/lib/hobo/hobo_helper.rb b/hobo/lib/hobo/hobo_helper.rb index 0fd0555..898804e 100644 --- a/hobo/lib/hobo/hobo_helper.rb +++ b/hobo/lib/hobo/hobo_helper.rb @@ -475,7 +475,7 @@ module Hobo # --- ViewHint Helpers --- # def this_field_name - this_parent.class.try.view_hints.try.field_name(this_field) || this_field + this_parent.class.human_attribute_name(this_field) end def this_field_help diff --git a/hobo/lib/hobo/model.rb b/hobo/lib/hobo/model.rb index 380f94e..b13e858 100644 --- a/hobo/lib/hobo/model.rb +++ b/hobo/lib/hobo/model.rb @@ -11,6 +11,7 @@ module Hobo def self.included(base) base.extend(ClassMethods) + base.extend(ViewHintExtensions) register_model(base) @@ -381,11 +382,6 @@ module Hobo end - def view_hints - class_name = "#{name}Hints" - class_name.safe_constantize or Object.class_eval("class #{class_name} < Hobo::ViewHints; end; #{class_name}") - end - end # --- of ClassMethods --- # diff --git a/hobo/lib/hobo/model/view_hint_extensions.rb b/hobo/lib/hobo/model/view_hint_extensions.rb new file mode 100644 index 0000000..248fcc8 --- /dev/null +++ b/hobo/lib/hobo/model/view_hint_extensions.rb @@ -0,0 +1,16 @@ +module Hobo + module Model + module ViewHintExtensions + def human_attribute_name(attribute_key_name, opt={}) + view_hints_field_names = self.view_hints.field_names + view_hints_field_names.include?(attribute_key_name.to_sym) ? + view_hints_field_names[attribute_key_name.to_sym] : super + end + + def view_hints + class_name = "#{name}Hints" + class_name.safe_constantize or Object.class_eval("class #{class_name} < Hobo::ViewHints; end; #{class_name}") + end + end + end +end diff --git a/hobo/taglibs/rapid_forms.dryml b/hobo/taglibs/rapid_forms.dryml index 01a0544..f11289c 100644 --- a/hobo/taglibs/rapid_forms.dryml +++ b/hobo/taglibs/rapid_forms.dryml @@ -692,7 +692,7 @@ The completions are provided by the server with a GET request. The `complete-tar

To proceed please correct the following:

-- 1.5.6.3