Skip to content

Commit 8cd288a

Browse files
authored
Merge pull request #53 from workgena/improve_input_html_options
Add support of Formtastic::String input_html
2 parents 36e27f6 + e522459 commit 8cd288a

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

lib/active_admin_datetimepicker/base.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ def input_html_data
1414
end
1515

1616
def input_html_options(input_name = nil, placeholder = nil)
17-
options = {}
18-
options[:class] = [self.options[:class], html_class].compact.join(' ')
19-
options[:data] ||= input_html_data
20-
options[:data].merge!(datepicker_options: datetime_picker_options)
21-
options[:value] ||= input_value(input_name)
22-
options[:maxlength] = 19
23-
options
17+
super().tap do |options|
18+
options[:class] = [self.options[:class], html_class].compact.join(' ')
19+
options[:data] ||= input_html_data
20+
options[:data].merge!(datepicker_options: datetime_picker_options)
21+
options[:value] ||= input_value(input_name)
22+
options[:maxlength] = 19
23+
options[:placeholder] = placeholder unless placeholder.nil?
24+
end
2425
end
2526

2627
def input_value(input_name = nil)

spec/filters_and_edit_form_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
expect(page.find('input#q_birthday_gteq').value).to start_with(date_from)
4040
expect(page.find('input#q_birthday_lteq').value).to start_with(date_to)
41+
expect(page).to have_css('input#q_birthday_gteq[placeholder="From"]')
42+
expect(page).to have_css('input#q_birthday_lteq[placeholder="To"]')
4143
end
4244
end
4345

@@ -59,6 +61,7 @@
5961
it 'can set birthday' do
6062
date_birthday = Date.today.beginning_of_month.strftime("%Y-%m-%d")
6163
expect(page.find('#author_birthday').value).to start_with(date_birthday)
64+
expect(page).to have_css('#author_birthday[placeholder="Formtastic placeholder"]')
6265
end
6366
end
6467

spec/support/admin.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def add_author_resource(options = {}, &block)
1010

1111
f.inputs 'General' do
1212
f.input :name
13-
f.input :birthday, as: :date_time_picker
13+
f.input :birthday, as: :date_time_picker, input_html: { placeholder: 'Formtastic placeholder' }
1414
end
1515

1616
f.actions

0 commit comments

Comments
 (0)