saveMinorUpdateFormValidation custom validation message is not working #1290
Replies: 5 comments
-
Based on the information provided in the knowledge sources, it appears that there was indeed an issue with custom validation messages in the According to the Editable Columns Changelog, version 3.0.6 (released on 20-Feb-2024) added support for custom validation messages:
However, I notice that you're using an older version of both Backpack CRUD (5.6) and Editable Columns (2.1). The fix for custom validation messages is available in version 3.0.6 and later of the Editable Columns package. To resolve this issue, I recommend updating your Backpack packages to the latest versions. You can do this by running:
After updating, make sure your "backpack/crud": "^6.x",
"backpack/editable-columns": "^3.0.6" If you're unable to update to the latest versions due to project constraints, you might need to implement a workaround. One possible approach is to override the public function saveMinorUpdate()
{
// Validate request
$this->saveMinorUpdateFormValidation();
// Update entry
$saved = $this->saveMinorUpdateEntry();
return [
'saved' => $saved,
'row' => $this->getMinorUpdateRow(),
];
} By overriding this method, you might have more control over how the validation errors are handled and returned. Remember to test thoroughly after making these changes to ensure everything works as expected in your specific setup. ℹ️ Please note our AI Bot does not reply to follow-ups, this will be the only AI answer in this thread. If the AI helped you find the answer, please mark it as answered or write details below so it can learn. Then close the conversation. If not, please give more information for when a human reads this. ℹ️ Relevant sources: Github Issue (closed): [Editable Columns] [Bug] [Minor improvement] Empty custom messages |
Beta Was this translation helpful? Give feedback.
-
Hey @blessen131 The correct code would be: // Assuming the column name is "status"
public function saveMinorUpdateFormValidation()
{
if (request('attribute') === 'status' && $this->minorUpdateEntry->status === 'completed') { // if $entry->status already "completed"
throw ValidationException::withMessages([
'status' => ['Cannot revert the status'],
]);
}
} |
Beta Was this translation helpful? Give feedback.
-
still not getting the custom message I am following the https://backpackforlaravel.com/products/editable-columns docs |
Beta Was this translation helpful? Give feedback.
-
Hey @blessen131 Your code is working for me. Screen.Recording.2025-02-05.at.2.20.40.PM.movBut I'm testing it on the latest version; Try |
Beta Was this translation helpful? Give feedback.
-
Could you please provide an example for the editable switch? Or Can I add alert inside that?
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to add custom validation for the editable column, but I am getting error message as 'The given data was invalid`
public function saveMinorUpdateFormValidation()
{
if (request('attribute') === 'completed' && request('value') !== 0) {
throw ValidationException::withMessages([
'completed' => ['Cannot revert the status'],
]);
}
}
"backpack/crud": "^5.6",
"backpack/editable-columns": "^2.1"
Beta Was this translation helpful? Give feedback.
All reactions