Fix Form_Utils to use component.$sid() instead of data-sid selector

Add response helper functions and use _message as reserved metadata key

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-23 22:38:48 +00:00
parent 678ff17ad6
commit 69af4e87d4
5 changed files with 73 additions and 14 deletions

View File

@@ -107,7 +107,8 @@ class Form_Utils {
// Resolve the promise once all animations are complete
Promise.all(animations).then(() => {
// Scroll to error container if it exists
const $error_container = $parent.find('[data-sid="error_container"]').first();
const component = $parent.component();
const $error_container = component ? component.$sid('error_container') : $();
if ($error_container.length > 0) {
const container_top = $error_container.offset().top;
@@ -251,9 +252,10 @@ class Form_Utils {
}
// Convert Laravel validator format {field: [msg1, msg2]} to {field: msg1}
// Skip reserved keys (prefixed with underscore) - these are metadata, not field errors
const normalized = {};
for (const field in errors) {
if (errors.hasOwnProperty(field)) {
if (errors.hasOwnProperty(field) && !field.startsWith('_')) {
const value = errors[field];
if (Array.isArray(value) && value.length > 0) {
normalized[field] = value[0];
@@ -345,7 +347,8 @@ class Form_Utils {
*/
static _apply_combined_error($parent, summary_msg, unmatched_errors) {
const animations = [];
const $error_container = $parent.find('[data-sid="error_container"]').first();
const component = $parent.component();
const $error_container = component ? component.$sid('error_container') : $();
const $target = $error_container.length > 0 ? $error_container : $parent;
// Create alert with summary message and bulleted list of unmatched errors
@@ -386,7 +389,8 @@ class Form_Utils {
const animations = [];
// Look for a specific error container div (e.g., in Rsx_Form component)
const $error_container = $parent.find('[data-sid="error_container"]').first();
const component = $parent.component();
const $error_container = component ? component.$sid('error_container') : $();
const $target = $error_container.length > 0 ? $error_container : $parent;
if (typeof messages === 'string') {