forked from fixin.me/fixin.me
Fix focus on form submit button
This commit is contained in:
@@ -3,27 +3,32 @@ module ApplicationHelper
|
||||
(field_helpers - [:label]).each do |selector|
|
||||
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
||||
def #{selector}(method, options = {})
|
||||
@template.content_tag :div, class: "form-row" do
|
||||
@template.content_tag :tr do
|
||||
label_text = label(method, options.delete(:label))
|
||||
label_class = ["form-label"]
|
||||
label_class << "required" if options[:required]
|
||||
label_class << "error" if @object&.errors[method].present?
|
||||
label_class = @template.class_names(required: options[:required],
|
||||
error: @object&.errors[method].present?)
|
||||
|
||||
@template.content_tag(:div, label_text, class: label_class) +
|
||||
@template.content_tag(:div, super, class: "form-field")
|
||||
@template.content_tag(:td, label_text, class: label_class) +
|
||||
@template.content_tag(:td, super)
|
||||
end
|
||||
end
|
||||
RUBY_EVAL
|
||||
end
|
||||
|
||||
def submit(value, options = {})
|
||||
@template.content_tag :div, super, class: "form-actions"
|
||||
@template.content_tag :tr do
|
||||
@template.content_tag :td, super, colspan: 2
|
||||
end
|
||||
end
|
||||
|
||||
def table_form_for(&block)
|
||||
@template.content_tag(:table) { yield(self) }
|
||||
end
|
||||
end
|
||||
|
||||
def tabular_form_for(record, options = {}, &block)
|
||||
options.merge! builder: TabularFormBuilder
|
||||
form_for(record, **options, &block)
|
||||
form_for(record, **options, &-> (f) { f.table_form_for(&block) })
|
||||
end
|
||||
|
||||
def image_link_to(name, image = nil, options = nil, html_options = nil)
|
||||
|
||||
Reference in New Issue
Block a user