Sha256: 262483e9d5b0eccb95b171cdb570fdfacb687309abe67a9a6f18ac0b448d8720
Contents?: true
Size: 1.28 KB
Versions: 20
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true require "primer/classify" module Primer module Forms # :nodoc: class Builder < ActionView::Helpers::FormBuilder include Primer::ClassNameHelper UTILITY_KEYS = Primer::Classify::Utilities::UTILITIES.keys.freeze def label(*args, **options, &block) super(*args, classify(options), &block) end def check_box(method, options = {}, checked_value = 1, unchecked_value = 0, &block) super(method, classify(options), checked_value, unchecked_value, &block) end def radio_button(*args, **options, &block) super(*args, classify(options), &block) end def select(*args, **options, &block) super(*args, classify(options), &block) end def text_field(*args, **options, &block) super(*args, classify(options), &block) end def text_area(*args, **options, &block) super(*args, classify(options), &block) end private def classify(options) options[:classes] = class_names(options.delete(:class), options[:classes]) options.merge!(Primer::Classify.call(options)) options.except!(*UTILITY_KEYS) options[:class] = class_names(options[:class], options.delete(:classes)) options end end end end
Version data entries
20 entries across 20 versions & 1 rubygems