Sha256: 21ef27110e0175e2337acd4a52a1523b4dae1d6226c4c23a8094c59e9fc4dc2e
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module Renalware module FormHelper def errors_css_class(model, attr) " field_with_errors" if model.errors.key?(attr) end def render_input(builder, attribute, html_options: {}) renderable = builder.object.public_send(attribute) return unless renderable render input_partial_path_for(renderable), attribute: attribute, f: builder, html_options: html_options end def input_partial_path_for(renderable) partial_type = partial_type_for(renderable) "renalware/shared/documents/#{partial_type}_input" end def partial_type_for(renderable) if renderable.respond_to?(:to_partial_path) renderable.to_partial_path.split("/").last else renderable.class.name.demodulize.underscore end end def monospace(value, width = 5) tag.span(class: "monospaced") do concat("%#{width}s" % value).gsub(/ /, " ").html_safe end end def save_or_cancel( form:, back_path:, submit_title: I18n.t("btn.save"), cancel_title: I18n.t("btn.cancel")&.downcase ) capture do concat(form.submit(submit_title, class: "button")) concat(tag.span { " #{I18n.t('btn.or')} " }) concat(link_to(cancel_title, back_path)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
renalware-core-2.1.1 | app/helpers/renalware/form_helper.rb |
renalware-core-2.1.0 | app/helpers/renalware/form_helper.rb |