Skip to content

Commit 17113f9

Browse files
authored
Merge pull request #454 from patriciomacadden/improve-boolean-fields
Improve boolean fields
2 parents e685718 + f1779db commit 17113f9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<%% end %>
1313

1414
<% attributes.each do |attribute| -%>
15-
<div class="my-5">
15+
<div class="my-5<%= " flex items-center gap-2" if attribute.field_type == :checkbox || attribute.field_type == :check_box %>">
1616
<% if attribute.password_digest? -%>
1717
<%%= form.label :password %>
1818
<%%= form.password_field :password, class: ["block shadow-sm rounded-md border px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:password].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:password].any?}] %>
@@ -29,7 +29,7 @@
2929
<% if attribute.field_type == :textarea || attribute.field_type == :text_area -%>
3030
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, rows: 4, class: ["block shadow-sm rounded-md border px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %>
3131
<% elsif attribute.field_type == :checkbox || attribute.field_type == :check_box -%>
32-
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: ["block shadow-sm rounded-md border mt-2 h-5 w-5", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %>
32+
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: ["block shadow-sm rounded-md border order-first h-5 w-5", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %>
3333
<% else -%>
3434
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: ["block shadow-sm rounded-md border px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %>
3535
<% end -%>

lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<%% <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
99
<div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div>
1010
<%% end %>
11+
<% elsif attribute.type == :boolean -%>
12+
<%%= <%= singular_name %>.<%= attribute.column_name %>? ? "Yes" : "No" %>
1113
<% else -%>
1214
<%%= <%= singular_name %>.<%= attribute.column_name %> %>
1315
<% end -%>

0 commit comments

Comments
 (0)