update form error styles

pull/105/head
Alex Turchyn 2 years ago
parent cdb1fd4c9f
commit 4905b13f25

@ -1,14 +1,18 @@
<% if resource.errors.any? %> <% if resource.errors.any? %>
<div id="error_explanation" data-turbo-cache="false"> <div id="error_explanation" data-turbo-cache="false">
<h2> <div class="alert">
<%= I18n.t('errors.messages.not_saved', <div>
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
<div>
<h3 class="font-bold">
<%= I18n.t('errors.messages.not_saved',
count: resource.errors.count, count: resource.errors.count,
resource: resource.class.model_name.human.downcase) %> resource: resource.class.model_name.human.downcase) %></h3>
</h2> <% resource.errors.full_messages.each do |message| %>
<ul> <p class="text-sm"><%= message %></p>
<% resource.errors.full_messages.each do |message| %> <% end %>
<li><%= message %></li> </div>
<% end %> </div>
</ul> </div>
</div> </div>
<% end %> <% end %>

@ -0,0 +1,4 @@
<% 'input-error' %>
<span class="label-text-alt text-red-400">
<%= message %>
</span>

@ -5,13 +5,12 @@
<div> <div>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current flex-shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current flex-shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<div> <div>
<h3 class="font-bold"> Store all files on disk</h3> <h3 class="font-bold">Store all files on disk</h3>
<p class="text-gray-700"> <p class="text-gray-700">
No configs are needed but make sure your disk is persistent No configs are needed but make sure your disk is persistent
<br> <br>
<i>(not suitable for Heroku and other PaaS)</i> <i>(not suitable for Heroku and other PaaS)</i>
</p> </p>
</div> </div>
</div> </div>
</div> </div>

@ -8,8 +8,12 @@ ActionView::Base.field_error_proc = proc do |html_tag, instance|
field_name = field_name =
instance.object.class.human_attribute_name(instance.instance_variable_get(:@method_name).to_s) instance.object.class.human_attribute_name(instance.instance_variable_get(:@method_name).to_s)
parsed_html_tag = Nokogiri::HTML::DocumentFragment.parse(html_tag)
parsed_html_tag.children.add_class 'input-error'
html_tag = parsed_html_tag.to_s.html_safe
result = html_tag result = html_tag
result += ApplicationController.helpers.tag.div("#{field_name} #{errors}") if errors.present? result += ApplicationController.helpers.tag.label(ApplicationController.render(partial: 'shared/field_error', locals: { message: "#{field_name} #{errors}" }), class: 'label') if errors.present?
result result
end end

Loading…
Cancel
Save