You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't directly an issue with unfold, but more a request or help with a UI issue I am facing.
I have enabled list editable on one of my django admin to allow user update the min and max value. I have set a validation in place to make sure that min is not greater than max. The validation works as expected. However, I am not really happy with the way the message is displayed.
So currently as seeing in the screenshot, the error message appears right above the field which messes up the alignment of the table. The column with error becomes wider than the others and it's not even highlighted with red.
What I am trying to achieve instead is to show the error on the top of the page like Please correct the errors below. Min value cannot be greater than max value
and simply have the errored field highlighted with red border.
It would be nice to make this part of the unfold package. However, if not, what is the best way to achieve this?
I tried overriding the is_valid function in my CustomModelForm but I can't add the messages there since I don't have access to the request object. Anything I tried to pass the request object was in vain.
class CustomModelForm(forms.ModelForm):
class Meta:
model = MyModel
fields = '__all__'
def is_valid(self):
if 'min_quantity' in self._errors:
# messages.error(self.request, self._errors["min_quantity"])
print("Handling a specific validation error for 'min'")
del self._errors['min_quantity']
super().is_valid()
The text was updated successfully, but these errors were encountered:
afsangujarati93
changed the title
Highlight list editable validation error
Validation Error Placement for List Editable Fields
May 11, 2024
This isn't directly an issue with unfold, but more a request or help with a UI issue I am facing.
I have enabled list editable on one of my django admin to allow user update the min and max value. I have set a validation in place to make sure that min is not greater than max. The validation works as expected. However, I am not really happy with the way the message is displayed.
So currently as seeing in the screenshot, the error message appears right above the field which messes up the alignment of the table. The column with error becomes wider than the others and it's not even highlighted with red.
What I am trying to achieve instead is to show the error on the top of the page like
Please correct the errors below.
Min value cannot be greater than max value
and simply have the errored field highlighted with red border.
It would be nice to make this part of the unfold package. However, if not, what is the best way to achieve this?
I tried overriding the
is_valid
function in myCustomModelForm
but I can't add the messages there since I don't have access to therequest
object. Anything I tried to pass the request object was in vain.The text was updated successfully, but these errors were encountered: