From a058a77c079c90445173e27a70ed144557f4e57f Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 18 Feb 2018 16:09:17 -0600 Subject: [PATCH] ApplicationHelper#search_field: accept html attributes on field. Rewrite `search_field` to allow setting `data-*` attributes on the field. --- app/helpers/application_helper.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4042152fd..88a257664 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -163,14 +163,14 @@ module ApplicationHelper submit_tag("Preview", "data-input-id" => options[:input_id], "data-preview-id" => options[:preview_id]) end - def search_field(method, options = {}) - name = options[:label] || method.titleize - string = '
' - if options[:hint] - string += '

' + options[:hint] + '

' + def search_field(method, label: method.titleize, hint: nil, value: nil, **attributes) + content_tag(:div, class: "input") do + label_html = label_tag("search_#{method}", label) + input_html = text_field_tag(method, value, id: "search_#{method}", name: "search[#{method}]", **attributes) + hint_html = hint.present? ? content_tag(:p, hint, class: "hint") : "" + + label_html + input_html + hint_html end - string += '
' - string.html_safe end def body_attributes(user = CurrentUser.user)