-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1846 from heartcombo/weekday-input
Add weekday select input.
- Loading branch information
Showing
5 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
module SimpleForm | ||
module Inputs | ||
class WeekdayInput < CollectionSelectInput | ||
enable :placeholder | ||
|
||
def input(wrapper_options = nil) | ||
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options) | ||
|
||
@builder.weekday_select(attribute_name, input_options, merged_input_options) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
# encoding: UTF-8 | ||
require 'test_helper' | ||
|
||
class WeekdayInputTest < ActionView::TestCase | ||
test 'input generates a weekday select' do | ||
if ActionView::VERSION::MAJOR >= 7 | ||
with_input_for @user, :born_at, :weekday | ||
assert_select 'select.weekday#user_born_at' | ||
end | ||
end | ||
|
||
test 'input generates a weekday select that accepts placeholder' do | ||
if ActionView::VERSION::MAJOR >= 7 | ||
with_input_for @user, :born_at, :weekday, placeholder: 'Put in a weekday' | ||
assert_select 'select.weekday[placeholder="Put in a weekday"]' | ||
end | ||
end | ||
end |