2014-10-14 18:27:28 +03:00
|
|
|
# Use this setup block to configure all options available in SimpleForm.
|
|
|
|
SimpleForm.setup do |config|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.error_notification_class = "alert alert-danger"
|
|
|
|
config.button_class = "btn btn-default"
|
2014-10-14 18:27:28 +03:00
|
|
|
config.boolean_label_class = nil
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.wrappers :vertical_form, tag: "div", class: "form-group", error_class: "has-error" do |b|
|
2014-10-14 18:27:28 +03:00
|
|
|
b.use :html5
|
|
|
|
b.use :placeholder
|
|
|
|
b.optional :maxlength
|
|
|
|
b.optional :pattern
|
|
|
|
b.optional :min_max
|
|
|
|
b.optional :readonly
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :label, class: "control-label"
|
2014-10-14 18:27:28 +03:00
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :input, class: "form-control"
|
|
|
|
b.use :error, wrap_with: {tag: "span", class: "help-block"}
|
|
|
|
b.use :hint, wrap_with: {tag: "p", class: "help-block"}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.wrappers :vertical_file_input, tag: "div", class: "form-group", error_class: "has-error" do |b|
|
2014-10-14 18:27:28 +03:00
|
|
|
b.use :html5
|
|
|
|
b.use :placeholder
|
|
|
|
b.optional :maxlength
|
|
|
|
b.optional :readonly
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :label, class: "control-label"
|
2014-10-14 18:27:28 +03:00
|
|
|
|
|
|
|
b.use :input
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :error, wrap_with: {tag: "span", class: "help-block"}
|
|
|
|
b.use :hint, wrap_with: {tag: "p", class: "help-block"}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.wrappers :vertical_boolean, tag: "div", class: "form-group", error_class: "has-error" do |b|
|
2014-10-14 18:27:28 +03:00
|
|
|
b.use :html5
|
|
|
|
b.optional :readonly
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
b.wrapper tag: "div", class: "checkbox" do |ba|
|
2014-10-14 18:27:28 +03:00
|
|
|
ba.use :label_input
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :error, wrap_with: {tag: "span", class: "help-block"}
|
|
|
|
b.use :hint, wrap_with: {tag: "p", class: "help-block"}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.wrappers :vertical_radio_and_checkboxes, tag: "div", class: "form-group", error_class: "has-error" do |b|
|
2014-10-14 18:27:28 +03:00
|
|
|
b.use :html5
|
|
|
|
b.optional :readonly
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :label, class: "control-label"
|
2015-04-20 16:22:36 +03:00
|
|
|
b.use :input
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :error, wrap_with: {tag: "span", class: "help-block"}
|
|
|
|
b.use :hint, wrap_with: {tag: "p", class: "help-block"}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.wrappers :horizontal_form, tag: "div", class: "form-group", error_class: "has-error" do |b|
|
2014-10-14 18:27:28 +03:00
|
|
|
b.use :html5
|
|
|
|
b.use :placeholder
|
|
|
|
b.optional :maxlength
|
|
|
|
b.optional :pattern
|
|
|
|
b.optional :min_max
|
|
|
|
b.optional :readonly
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :label, class: "col-sm-3 control-label"
|
2014-10-14 18:27:28 +03:00
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
b.wrapper tag: "div", class: "col-sm-9" do |ba|
|
|
|
|
ba.use :input, class: "form-control"
|
|
|
|
ba.use :error, wrap_with: {tag: "span", class: "help-block"}
|
|
|
|
ba.use :hint, wrap_with: {tag: "p", class: "help-block"}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.wrappers :horizontal_file_input, tag: "div", class: "form-group", error_class: "has-error" do |b|
|
2014-10-14 18:27:28 +03:00
|
|
|
b.use :html5
|
|
|
|
b.use :placeholder
|
|
|
|
b.optional :maxlength
|
|
|
|
b.optional :readonly
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :label, class: "col-sm-3 control-label"
|
2014-10-14 18:27:28 +03:00
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
b.wrapper tag: "div", class: "col-sm-9" do |ba|
|
2014-10-14 18:27:28 +03:00
|
|
|
ba.use :input
|
2019-04-28 21:10:54 +03:00
|
|
|
ba.use :error, wrap_with: {tag: "span", class: "help-block"}
|
|
|
|
ba.use :hint, wrap_with: {tag: "p", class: "help-block"}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.wrappers :horizontal_boolean, tag: "div", class: "form-group", error_class: "has-error" do |b|
|
2014-10-14 18:27:28 +03:00
|
|
|
b.use :html5
|
|
|
|
b.optional :readonly
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
b.wrapper tag: "div", class: "col-sm-offset-3 col-sm-9" do |wr|
|
|
|
|
wr.wrapper tag: "div", class: "checkbox" do |ba|
|
|
|
|
ba.use :label_input, class: "col-sm-9"
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
wr.use :error, wrap_with: {tag: "span", class: "help-block"}
|
|
|
|
wr.use :hint, wrap_with: {tag: "p", class: "help-block"}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.wrappers :horizontal_radio_and_checkboxes, tag: "div", class: "form-group", error_class: "has-error" do |b|
|
2014-10-14 18:27:28 +03:00
|
|
|
b.use :html5
|
|
|
|
b.optional :readonly
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :label, class: "col-sm-3 control-label"
|
2014-10-14 18:27:28 +03:00
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
b.wrapper tag: "div", class: "col-sm-9" do |ba|
|
2014-10-14 18:27:28 +03:00
|
|
|
ba.use :input
|
2019-04-28 21:10:54 +03:00
|
|
|
ba.use :error, wrap_with: {tag: "span", class: "help-block"}
|
|
|
|
ba.use :hint, wrap_with: {tag: "p", class: "help-block"}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
config.wrappers :inline_form, tag: "div", class: "form-group", error_class: "has-error" do |b|
|
2014-10-14 18:27:28 +03:00
|
|
|
b.use :html5
|
|
|
|
b.use :placeholder
|
|
|
|
b.optional :maxlength
|
|
|
|
b.optional :pattern
|
|
|
|
b.optional :min_max
|
|
|
|
b.optional :readonly
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :label, class: "sr-only"
|
2014-10-14 18:27:28 +03:00
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
b.use :input, class: "form-control"
|
|
|
|
b.use :error, wrap_with: {tag: "span", class: "help-block"}
|
|
|
|
b.use :hint, wrap_with: {tag: "p", class: "help-block"}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
# Wrappers for forms and inputs using the Bootstrap toolkit.
|
|
|
|
# Check the Bootstrap docs (http://getbootstrap.com)
|
|
|
|
# to learn about the different styles for forms and inputs,
|
|
|
|
# buttons and other elements.
|
2015-04-20 16:22:36 +03:00
|
|
|
config.default_wrapper = :vertical_form
|
|
|
|
config.wrapper_mappings = {
|
|
|
|
check_boxes: :vertical_radio_and_checkboxes,
|
|
|
|
radio_buttons: :vertical_radio_and_checkboxes,
|
|
|
|
file: :vertical_file_input,
|
|
|
|
boolean: :vertical_boolean,
|
|
|
|
}
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|