a11yist/app/helpers/application_helper.rb

20 lines
541 B
Ruby
Raw Normal View History

2024-07-15 14:31:54 +02:00
# frozen_string_literal: true
module ApplicationHelper
2024-07-21 00:33:38 +02:00
include Pagy::Frontend
delegate :filter_params, to: :controller
2024-09-05 22:54:38 +02:00
def multilang_form_field(form, attribute, as: :text_field)
col_width = as == :rich_text_area ? 12 : 12 / I18n.available_locales.count
tag.div(class: "row") do
fields = I18n.available_locales.map { _1.to_s.split("-").first }.map do |lang|
tag.div(class: "col-lg-#{col_width}") do
form.send(as, "#{attribute}_#{lang}")
end
end
safe_join(fields)
end
end
end