From 67b13e02faff54db62b3b51c2064e2d90fc4e0d6 Mon Sep 17 00:00:00 2001 From: Godwin Date: Fri, 15 Jul 2016 08:24:56 -0700 Subject: [PATCH] Fixed HTML5 errors --- app/helpers/application_helper.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7886722..49efe68 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1100,7 +1100,7 @@ module ApplicationHelper def textfield(name, value, options = {}) html = '' - id = name.to_s.gsub('[', '_').gsub(']', '') + id = unique_id(name) description_id = nil if options[:heading].present? @@ -1149,7 +1149,13 @@ module ApplicationHelper case options[:type] when :select - html += select_tag(name, options_for_select(options[:options], value), input_options) + option_list = options_for_select(options[:options], value) + + # make sure that we have an empty option if the select is required + if options[:required] && options[:options].first.present? && options[:options].first.last.present? + option_list = ('' + option_list).html_safe + end + html += select_tag(name, option_list, input_options) else html += send("#{(options[:type] || :text).to_s}_field_tag", name, value, input_options) end @@ -1273,7 +1279,7 @@ module ApplicationHelper options[:big] ? 'big' : nil ].compact).html_safe, aria: { - labeledby: label_id, + labelledby: label_id, describedby: description_id }, class: [