update form error styles

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

@ -1,14 +1,18 @@
<% if resource.errors.any? %>
<div id="error_explanation" data-turbo-cache="false">
<h2>
<%= I18n.t('errors.messages.not_saved',
<div class="alert">
<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,
resource: resource.class.model_name.human.downcase) %>
</h2>
<ul>
<% resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
resource: resource.class.model_name.human.downcase) %></h3>
<% resource.errors.full_messages.each do |message| %>
<p class="text-sm"><%= message %></p>
<% end %>
</div>
</div>
</div>
</div>
<% end %>

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

@ -5,13 +5,12 @@
<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>
<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">
No configs are needed but make sure your disk is persistent
<br>
<i>(not suitable for Heroku and other PaaS)</i>
</p>
</div>
</div>
</div>

@ -8,8 +8,12 @@ ActionView::Base.field_error_proc = proc do |html_tag, instance|
field_name =
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 += 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
end

Loading…
Cancel
Save