Module: Decidim::Toggle::InformativeCallouts

Extended by:
ActiveSupport::Concern
Included in:
UpdateOmniauthForm
Defined in:
lib/decidim/toggle/informative_callouts.rb

Overview

Declare form-level informative callouts (info, warning, danger) on toggle settings forms.

class MyForm < Decidim::Form
include Decidim::Toggle::InformativeCallouts

info :management_callout_html
warning :conditional_callout, if_predicate: ->(form) { form.some_flag? }

def management_callout_html
  I18n.t("...")
end
end

message is always a Symbol naming an instance method on the form. Messages are rendered as HTML (sanitized by the announcement cell), wrapped in decidim_toggle_informative_callout for system typography styles.

Defined Under Namespace

Classes: InformativeEntry

Constant Summary collapse

WRAPPER_CLASS =
"decidim_toggle_informative_callout"
CALLOUT_TYPES =
[:info, :warning, :danger].freeze

Instance Method Summary collapse

Instance Method Details

#visible_informative_calloutsObject



71
72
73
# File 'lib/decidim/toggle/informative_callouts.rb', line 71

def visible_informative_callouts
  self.class.informative_callouts.select { |entry| entry.visible?(self) }
end