Add “Glitch-only” label to glitch-specific settings

This commit is contained in:
Claire
2022-11-12 10:09:27 +01:00
parent c813df2ebb
commit 6a96b17a2d
8 changed files with 27 additions and 8 deletions

View File

@ -19,8 +19,17 @@ module RecommendedComponent
end
end
module GlitchOnlyComponent
def glitch_only(_wrapper_options = nil)
return unless options[:glitch_only]
options[:label_text] = ->(raw_label_text, _required_label_text, _label_present) { safe_join([raw_label_text, ' ', content_tag(:span, I18n.t('simple_form.glitch_only'), class: 'glitch_only')]) }
nil
end
end
SimpleForm.include_component(AppendComponent)
SimpleForm.include_component(RecommendedComponent)
SimpleForm.include_component(GlitchOnlyComponent)
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
@ -78,6 +87,7 @@ SimpleForm.setup do |config|
b.wrapper tag: :div, class: :label_input do |ba|
ba.optional :recommended
ba.optional :glitch_only
ba.use :label
ba.wrapper tag: :div, class: :label_input__wrapper do |bb|