app/views/shared/_fields.html.erb in zutils-0.5.1 vs app/views/shared/_fields.html.erb in zutils-1.0.0
- old
+ new
@@ -1,16 +1,21 @@
<% excluded_columns ||= [] %>
<% additional_columns ||= [] %>
<% restricted_columns ||= {} %>
+<% show_columns ||= [] %>
<% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
<% form_ordered_fields ||= (form_fields.empty? ? object.class.column_names : form_fields.keys) %>
+<% if show_columns.empty? %>
+ <% show_columns = form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns %>
+<% end %>
+
<div class="row">
- <% (form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns).each do |column| %>
+ <% show_columns.each do |column| %>
<% wphtml = "col-md-#{(form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:size] : form_fields[column.to_sym] ) || 12}" %>
- <% hint = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:hint] : '') %>
- <% placeholder = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:placeholder] : '') %>
+ <% hint = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:hint] : nil) %>
+ <% placeholder = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:placeholder] : nil) %>
<% if object.class.column_for_attribute(column).type == :text %>
<%= f.input column, input_html: { rows: 10, cols: 20 }, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
<% elsif [:date, :datetime].include?(object.class.column_for_attribute(column).type) %>
<%= f.input column, html5: true, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
<% elsif object.send(column).respond_to? 'attached?' %>