app/helpers/dry_crud/form/builder.rb in dry_crud-5.2.0 vs app/helpers/dry_crud/form/builder.rb in dry_crud-6.0.0
- old
+ new
@@ -71,13 +71,11 @@
# Render a boolean field.
def boolean_field(attr, html_options = {})
content_tag(:div, class: 'checkbox') do
content_tag(:label) do
- # rubocop:disable Rails/OutputSafety
detail = html_options.delete(:detail) || ' '.html_safe
- # rubocop:enable Rails/OutputSafety
safe_join([check_box(attr, html_options), ' ', detail])
end
end
end
@@ -88,19 +86,31 @@
add_css_class(html_options, 'form-control')
super(attr, html_options)
end
end
+ def integer_field(attr, html_options = {})
+ html_options[:step] ||= 1
+ number_field(attr, html_options)
+ end
+
+ def float_field(attr, html_options = {})
+ html_options[:step] ||= 'any'
+ number_field(attr, html_options)
+ end
+
+ def decimal_field(attr, html_options = {})
+ html_options[:step] ||=
+ (10**-column_property(object, attr, :scale)).to_f
+ number_field(attr, html_options)
+ end
+
# Customize the standard text area to have 5 rows by default.
def text_area(attr, html_options = {})
add_css_class(html_options, 'form-control')
html_options[:rows] ||= 5
super(attr, html_options)
end
-
- alias integer_field number_field
- alias float_field number_field
- alias decimal_field number_field
# Render a select element for a :belongs_to association defined by attr.
# Use additional html_options for the select element.
# To pass a custom element list, specify the list with the :list key or
# define an instance variable with the pluralized name of the