diff --git a/lib/simple_form/form_builder.rb b/lib/simple_form/form_builder.rb index af281cf3c..6856f5faf 100644 --- a/lib/simple_form/form_builder.rb +++ b/lib/simple_form/form_builder.rb @@ -26,6 +26,7 @@ class FormBuilder < ActionView::Helpers::FormBuilder map_type :range, to: SimpleForm::Inputs::RangeInput map_type :check_boxes, to: SimpleForm::Inputs::CollectionCheckBoxesInput map_type :radio_buttons, to: SimpleForm::Inputs::CollectionRadioButtonsInput + map_type :rich_text_area, to: SimpleForm::Inputs::RichTextAreaInput map_type :select, to: SimpleForm::Inputs::CollectionSelectInput map_type :grouped_select, to: SimpleForm::Inputs::GroupedCollectionSelectInput map_type :date, :time, :datetime, to: SimpleForm::Inputs::DateTimeInput diff --git a/lib/simple_form/inputs.rb b/lib/simple_form/inputs.rb index 25cb7cbce..2485d3914 100644 --- a/lib/simple_form/inputs.rb +++ b/lib/simple_form/inputs.rb @@ -19,6 +19,7 @@ module Inputs autoload :PasswordInput autoload :PriorityInput autoload :RangeInput + autoload :RichTextAreaInput autoload :StringInput autoload :TextInput end diff --git a/lib/simple_form/inputs/rich_text_area_input.rb b/lib/simple_form/inputs/rich_text_area_input.rb new file mode 100644 index 000000000..61695758a --- /dev/null +++ b/lib/simple_form/inputs/rich_text_area_input.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +module SimpleForm + module Inputs + class RichTextAreaInput < Base + def input(wrapper_options = nil) + merged_input_options = merge_wrapper_options(input_html_options, wrapper_options) + + @builder.rich_text_area(attribute_name, merged_input_options) + end + end + end +end diff --git a/test/inputs/rich_text_area_input_test.rb b/test/inputs/rich_text_area_input_test.rb new file mode 100644 index 000000000..15d12a589 --- /dev/null +++ b/test/inputs/rich_text_area_input_test.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true +# encoding: UTF-8 +require 'test_helper' + +class RichTextAreaInputTest < ActionView::TestCase + test 'input generates a text area for text attributes' do + with_input_for @user, :description, :text + assert_select 'textarea.text#user_description' + end + + test 'input generates a text area for text attributes that accept placeholder' do + with_input_for @user, :description, :text, placeholder: 'Put in some text' + assert_select 'textarea.text[placeholder="Put in some text"]' + end +end