Module: CKEditor5::Rails::Hooks::Form::FormBuilderExtension

Defined in:
lib/ckeditor5/rails/hooks/form.rb

Instance Method Summary collapse

Instance Method Details

#ckeditor5(method, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ckeditor5/rails/hooks/form.rb', line 6

def ckeditor5(method, options = {})
  value = if object.respond_to?(method)
            object.send(method)
          else
            options[:initial_data]
          end

  html_options = options.merge(
    name: object_name,
    required: options.delete(:required),
    initial_data: value
  )

  @template.ckeditor5_editor(**html_options)
end