From 9ecdd10b2dde10ed5c1648cd561d90960fc5ec66 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Wed, 17 May 2023 23:38:41 +0200 Subject: [PATCH] Fix passing options for form fields --- app/helpers/application_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4ee7125..998c020 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,13 +3,13 @@ module ApplicationHelper (field_helpers - [:label]).each do |selector| class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 def #{selector}(method, options = {}) - labelled_row_for(method, super, options) + labelled_row_for(method, options) { super } end RUBY_EVAL end def select(method, choices = nil, options = {}, html_options = {}) - labelled_row_for(method, super, options) + labelled_row_for(method, options) { super } end def submit(value, options = {}) @@ -26,10 +26,10 @@ module ApplicationHelper private - def labelled_row_for(method, field, options) + def labelled_row_for(method, options) @template.content_tag :tr do @template.content_tag(:td, label_for(method, options)) + - @template.content_tag(:td, options.delete(:readonly) ? @object.public_send(method) : field, + @template.content_tag(:td, options.delete(:readonly) ? @object.public_send(method) : yield, @object&.errors[method].present? ? {class: "error", data: {content: @object&.errors.delete(method).join(" and ")}} : {})