aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb19
-rw-r--r--app/helpers/config_helper.rb4
2 files changed, 23 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index ec56566a9..a0f16dfaf 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -94,5 +94,24 @@ module ApplicationHelper
block.call
end
end
+ # (unfortunately) ugly way of getting id of generated form element
+ # ids
+ # see http://chrisblunt.com/2009/10/12/rails-getting-the-id-of-form-fields-inside-a-fields_for-block/
+ def sanitized_object_name(object_name)
+ object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/,"_").sub(/_$/,"")
+ end
+
+ def sanitized_method_name(method_name)
+ method_name.sub(/\?$/, "")
+ end
+
+ def form_tag_id(object_name, method_name, locale=nil)
+ if locale.nil?
+ return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}"
+ else
+ return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}__#{locale.to_s}"
+ end
+ end
+
end
diff --git a/app/helpers/config_helper.rb b/app/helpers/config_helper.rb
index 80f2deed2..b0381a2f5 100644
--- a/app/helpers/config_helper.rb
+++ b/app/helpers/config_helper.rb
@@ -2,4 +2,8 @@ module ConfigHelper
def site_name
MySociety::Config.get('SITE_NAME', 'Alaveteli')
end
+
+ def force_registration_on_new_request
+ MySociety::Config.get('FORCE_REGISTRATION_ON_NEW_REQUEST', false)
+ end
end \ No newline at end of file