Improve form fields with errors for model updates
This commit is contained in:
parent
9048052318
commit
61f12c2741
@ -32,8 +32,4 @@
|
|||||||
@apply bg-red-600 hover:bg-red-700 text-white
|
@apply bg-red-600 hover:bg-red-700 text-white
|
||||||
focus:ring-red-500 focus:ring-opacity-75;
|
focus:ring-red-500 focus:ring-opacity-75;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=text]:disabled {
|
|
||||||
@apply text-gray-700;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,13 @@
|
|||||||
focus:ring-blue-600 focus:ring-opacity-75;
|
focus:ring-blue-600 focus:ring-opacity-75;
|
||||||
}
|
}
|
||||||
|
|
||||||
.field_with_errors {
|
input[type=text]:disabled,
|
||||||
@apply inline-block;
|
input[type=email]:disabled {
|
||||||
|
@apply text-gray-700;
|
||||||
}
|
}
|
||||||
|
|
||||||
.field_with_errors input {
|
input.field_with_errors {
|
||||||
@apply w-full bg-red-100;
|
@apply border-b-red-600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error-msg {
|
.error-msg {
|
||||||
|
9
config/initializers/field_with_errors.rb
Normal file
9
config/initializers/field_with_errors.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
|
||||||
|
if html_tag.match('class')
|
||||||
|
html_tag.gsub(/class="(.*?)"/, 'class="\1 field_with_errors"').html_safe
|
||||||
|
else
|
||||||
|
parts = html_tag.split('>', 2)
|
||||||
|
parts[0] += ' class="field_with_errors">'
|
||||||
|
(parts[0] + parts[1]).html_safe
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user