55use Backpack \CRUD \app \View \Components \Contracts \IsolatesOperationSetup ;
66use Closure ;
77
8- class DataformModal extends DataForm implements IsolatesOperationSetup
8+ class DataformModal extends Dataform implements IsolatesOperationSetup
99{
1010 /**
1111 * Modal forms ALWAYS isolate their operation setup.
@@ -16,28 +16,11 @@ public function shouldIsolateOperationSetup(): bool
1616 return true ;
1717 }
1818
19- /**
20- * Create a new component instance.
21- *
22- * @param string $controller The CRUD controller class name
23- * @param string $operation The operation to use (create, update, etc.)
24- * @param string|null $action Custom form action URL
25- * @param string $method Form method (post, put, etc.)
26- * @param bool $hasUploadFields Whether the form has upload fields
27- * @param mixed|null $entry The model instance for update operations
28- * @param Closure|null $setup A closure to customize the CRUD panel
29- * @param string $formRouteOperation The operation to use for the form route (defaults to 'create')
30- * @param string $id The ID for the form element (defaults to 'backpack-form')
31- * @param bool $focusOnFirstField Whether to focus on the first field when form loads
32- * @param string $title The title of the modal
33- * @param string $classes CSS classes for the modal dialog
34- * @param bool $refreshDatatable Whether to refresh the datatable after form submission
35- */
3619 public string $ hashedFormId ;
3720
3821 public function __construct (
3922 public string $ controller ,
40- public ?string $ route = null , // Accept route as an optional parameter
23+ public ?string $ route = null ,
4124 public string $ id = 'backpack-form ' ,
4225 public string $ operation = 'create ' ,
4326 public string $ name = '' ,
@@ -60,12 +43,10 @@ public function __construct(
6043 \Backpack \CRUD \CrudManager::unsetActiveController ();
6144 }
6245
63- // Use the provided/resolved route instead of calling setupCrudPanel on every render
64- // This avoids operation switching during page load when route is provided
65- $ action = $ this ->action ?? url ($ this ->route );
46+ $ this ->action = $ this ->action ?? url ($ this ->route );
6647
67- // Generate the SAME hashed form ID that the DataForm component uses
68- $ this ->hashedFormId = $ this ->id .md5 ($ action .$ this ->operation .'post ' .$ this ->controller );
48+ // Generate the SAME hashed form ID that the Dataform component uses
49+ $ this ->hashedFormId = $ this ->id .md5 ($ action .$ this ->operation .'post ' .$ this ->controller );
6950
7051 // Cache the setup closure if provided (for retrieval during AJAX request)
7152 if ($ this ->setup instanceof \Closure) {
@@ -76,7 +57,8 @@ public function __construct(
7657 // the CRUD panel on page load - the form will be loaded via AJAX
7758
7859 if ($ this ->entry && $ this ->operation === 'update ' ) {
79- $ this ->formRouteOperation = url ($ action .'/ ' .$ this ->entry ->getKey ().'/edit ' );
60+ // Use the resolved action (base route) to build the edit URL for the entry
61+ $ this ->formRouteOperation = url ($ this ->action .'/ ' .$ this ->entry ->getKey ().'/edit ' );
8062 }
8163 }
8264
@@ -91,7 +73,7 @@ protected function cacheSetupClosure(): void
9173
9274 // Apply and cache the setup closure using the HASHED ID
9375 \Backpack \CRUD \app \Library \Support \DataformCache::applyAndStoreSetupClosure (
94- $ this ->hashedFormId , // Use the hashed ID that matches what DataForm component generates
76+ $ this ->hashedFormId , // Use the hashed ID that matches what Dataform component generates
9577 $ this ->controller ,
9678 $ this ->setup ,
9779 null ,
0 commit comments