]> git.openstreetmap.org Git - rails.git/blob - lib/bootstrap_form/inputs/richtext_field.rb
Use an inline list for the login auth buttons
[rails.git] / lib / bootstrap_form / inputs / richtext_field.rb
1 # frozen_string_literal: true
2
3 # A custom richtext_field form group. By using form_group_builder we get to use
4 # the built-in methods for generating labels and help text.
5 module BootstrapForm
6   module Inputs
7     module RichtextField
8       extend ActiveSupport::Concern
9       include Base
10
11       # It's not clear to me why this needs to be duplicated from the upstream BootstrapForm::FormBuilder class
12       delegate :content_tag, :capture, :concat, :tag, :to => :@template
13
14       included do
15         def richtext_field_with_bootstrap(name, options = {})
16           id = "#{@object_name}_#{name}"
17           type = options.delete(:format) || "markdown"
18
19           form_group_builder(name, options) do
20             @template.render(:partial => "shared/richtext_field",
21                              :locals => { :object => @object,
22                                           :attribute => name,
23                                           :object_name => @object_name,
24                                           :id => id,
25                                           :type => type,
26                                           :options => options,
27                                           :builder => self })
28           end
29         end
30
31         alias_method :richtext_field, :richtext_field_with_bootstrap
32       end
33     end
34   end
35 end