From 1f3e7964b7db644e68de2db11503ca2cf6b9fac1 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 11 Oct 2016 11:45:00 +0200 Subject: [PATCH] Add smarter placeholders to content forms --- app/views/content/form/_text_input.html.erb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/content/form/_text_input.html.erb b/app/views/content/form/_text_input.html.erb index 232dab7e..cc324d13 100644 --- a/app/views/content/form/_text_input.html.erb +++ b/app/views/content/form/_text_input.html.erb @@ -1,5 +1,6 @@ <% field_id = "#{f.object.class.name.downcase}_#{attribute}" + class_name = f.object.class.name.downcase # TODO: Enable autocomplete when we can actually hide the dropdown if someone tabs out of a field. # Not the easiest thing in the world to do, apparently. @@ -7,7 +8,15 @@
<%= f.label attribute, attribute.humanize.capitalize %> - <%= f.text_area attribute, class: "materialize-textarea #{defined?(autocomplete) && false ? 'autocomplete' : ''}", placeholder: 'Write as little or as much as you want!' %> + <% + placeholder = t("serendipitous_questions.attributes.#{class_name}.#{attribute}") + placeholder = I18n.translate "attributes.#{class_name}.#{attribute}", + scope: :serendipitous_questions, + name: f.object.send('name') || "this #{class_name}", + attribute: "test", + default: 'Write as little or as much as you want!' + %> + <%= f.text_area attribute, class: "materialize-textarea #{defined?(autocomplete) && false ? 'autocomplete' : ''}", placeholder: placeholder %>
<% if defined?(autocomplete) && false %>