Skip to content

Commit

Permalink
Merge pull request #1646 from morsedigital/master
Browse files Browse the repository at this point in the history
Added RichTextAreaInput for ActionText
  • Loading branch information
feliperenan authored Feb 6, 2020
2 parents a05b95d + 3b3ab24 commit e1b3601
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/simple_form/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/simple_form/inputs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Inputs
autoload :PasswordInput
autoload :PriorityInput
autoload :RangeInput
autoload :RichTextAreaInput
autoload :StringInput
autoload :TextInput
end
Expand Down
12 changes: 12 additions & 0 deletions lib/simple_form/inputs/rich_text_area_input.rb
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions test/inputs/rich_text_area_input_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e1b3601

Please sign in to comment.