File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
app/inputs/active_admin/inputs Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,10 @@ class ActiveAdmin::Inputs::SelectInput < Formtastic::Inputs::SelectInput
2
2
def input_html_options
3
3
super . merge ( data : { tags : @options [ :tags ] . present? } )
4
4
end
5
+
6
+ def raw_collection
7
+ field_value = object . send ( method )
8
+
9
+ @options [ :tags ] . present? && field_value . present? ? ( super . to_a << field_value ) . uniq : super
10
+ end
5
11
end
Original file line number Diff line number Diff line change 40
40
expect_select2_options_count_to_eq ( 5 )
41
41
end
42
42
end
43
+
44
+ context 'when initial value is not in inputs collection' do
45
+ before do
46
+ invoice . update! ( number : selection )
47
+ visit edit_admin_invoice_path ( invoice )
48
+ end
49
+
50
+ it "includes initial value as option" , js : true do
51
+ expect_select2_options_count_to_eq ( 5 )
52
+ end
53
+ end
43
54
end
44
55
45
56
context "with tags: false option" do
You can’t perform that action at this time.
0 commit comments