Skip to content

Add class option to dropdown form selects #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/concepts/matestack/ui/core/form/select/select.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
%select{"#{model_binding}" => input_key,
id: component_id,
ref: "select.#{attr_key}",
class: options[:class],
"@change": "inputChanged(\"#{attr_key}\")",
"init-value": init_value,
"value-type": options_type}
Expand Down
31 changes: 31 additions & 0 deletions spec/usage/components/form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,37 @@ def form_config

it "can have a placeholder"

it "can have a class" do
class ExamplePage < Matestack::Ui::Page
def response
components {
form form_config, :include do
form_select id: "my-array-test-dropdown", key: :array_input, type: :dropdown, options: ["Array Option 1","Array Option 2"], class: "form-control"
form_select id: "my-hash-test-dropdown", key: :hash_input, type: :dropdown, options: { "1": "Hash Option 1", "2": "Hash Option 2" }, class: "form-control"
form_submit do
button text: "Submit me!"
end
end
}
end

def form_config
return {
for: :my_object,
method: :post,
path: :success_form_test_path,
params: {
id: 42
}
}
end
end

visit "/example"

expect(page).to have_css("#my-array-test-dropdown.form-control")
expect(page).to have_css("#my-hash-test-dropdown.form-control")
end
end

describe "Checkbox" do
Expand Down