"use strict"; /** * Rsx_Form * * Form container with validation, submission, and widget value management. * See rsx_form.jqhtml for full documentation. * * JavaScript Responsibilities: * - Parses and stores initial form data from $data attribute (JSON or object) * - Discovers and manages child Widget components via vals() getter/setter * - Handles form submission via Ajax to controller/method endpoints * - Applies validation errors to fields using Form_Utils * - Integrates with Rsx_Tabs for tab-aware error handling * - Provides seed() functionality for debug/testing * - Manages form state (values, errors) throughout lifecycle */ class Rsx_Form extends Component { on_create() { this.data.values = {}; // Current form values {name: value} this.data.errors = {}; // Validation errors {name: error_message} this.tabs = null; // Reference to Rsx_Tabs component if present // Parse initial data from $data attribute (e.g., from $data=$client) let data = this.args.data; if (typeof data === 'string') { try { // Decode HTML entities before parsing JSON // This handles cases where JSON is passed through Blade {!! !!} syntax const decoded = $('