Add a custom validator looking for {required,checked}={true,false} attributes. This found numerous cases. Add an html_attrs method that handles required/checked attributes properly, skipping them if the value is false, and using them without a value if the value is true. Change all attribute handling to use html_attrs to fix the issue.
38 lines
1.4 KiB
Plaintext
38 lines
1.4 KiB
Plaintext
<% name ||= nil
|
|
label ||= nil
|
|
range_labels ||= {}
|
|
value = flash.dig("old", name) || value || 0
|
|
error ||= rodauth.field_error(name) || flash.dig("errors", name)
|
|
description ||= nil
|
|
attributes ||= {}
|
|
extra_class ||= {} %>
|
|
|
|
<div class="space-y-2 text-gray-900">
|
|
<% if label %>
|
|
<label for="<%= name %>" class="block text-sm font-medium leading-6"><%= label %></label>
|
|
<% end %>
|
|
<div class="flex flex-col space-y-2 p-2">
|
|
<input
|
|
id="<%= name %>"
|
|
type="range"
|
|
name="<%= name %>"
|
|
<% if value %>
|
|
value="<%= value %>"
|
|
<% end %>
|
|
class="w-full range-lg h-2 bg-gray-200 accent-orange-600 rounded-lg appearance-none cursor-pointer border-transparent <%=extra_class %> <%= error ? "text-red-900 ring-red-300 focus:ring-red-500" : "text-gray-900 ring-gray-300 focus:ring-orange-600"%>"
|
|
<%== html_attrs(attributes) %>
|
|
>
|
|
<ul class="flex justify-between w-full px-[10px] pt-2 sm:pt-8">
|
|
<% range_labels.each do |lbl| %>
|
|
<li class="flex justify-right sm:justify-center relative items-center rotate-90 sm:rotate-0 mb-6 sm:mb-0"><span class="absolute text-center"><%= lbl %></span></li>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
<% if error %>
|
|
<p class="text-sm text-red-600 leading-6" id="<%= name %>-error"><%= error %></p>
|
|
<% end %>
|
|
<% if description %>
|
|
<p class="text-sm text-gray-500 leading-6" id="<%= name %>-description"><%== description %></p>
|
|
<% end %>
|
|
</div>
|