@@ -280,7 +280,7 @@ public function addElementAttr($content, $selector)
280280 $ crawler = new Crawler ($ content );
281281
282282 $ node = $ crawler ->filter ($ selector )->getNode (0 );
283- $ node ->setAttribute ('modal ' , $ this ->modalId );
283+ $ node ->setAttribute ('modal ' , $ this ->getModalId () );
284284
285285 return $ crawler ->children ()->html ();
286286 }
@@ -368,29 +368,44 @@ protected function resolveView($class)
368368 }
369369
370370 /**
371- * @param string $modalID
371+ * @return void
372372 */
373- public function addModalHtml ($ modalID )
373+ public function addModalHtml ()
374374 {
375375 $ data = [
376376 'fields ' => $ this ->fields ,
377377 'title ' => $ this ->action ->name (),
378- 'modal_id ' => $ modalID ,
378+ 'modal_id ' => $ this -> getModalId () ,
379379 ];
380380
381381 $ modal = view ('admin::actions.form.modal ' , $ data )->render ();
382382
383383 Admin::html ($ modal );
384384 }
385385
386+ /**
387+ * @return string
388+ */
389+ protected function getModalId ()
390+ {
391+ if (!$ this ->modalId ) {
392+
393+ if ($ this ->action instanceof RowAction) {
394+ $ this ->modalId = uniqid ('row-action-modal- ' );
395+ } else {
396+ $ this ->modalId = strtolower (str_replace ('\\' , '- ' , get_class ($ this ->action )));
397+ }
398+ }
399+
400+ return $ this ->modalId ;
401+ }
402+
386403 /**
387404 * @return void
388405 */
389406 public function addScript ()
390407 {
391- $ this ->modalId = uniqid ('action-modal- ' );
392-
393- $ this ->action ->attribute ('modal ' , $ this ->modalId );
408+ $ this ->action ->attribute ('modal ' , $ this ->getModalId ());
394409
395410 $ parameters = json_encode ($ this ->action ->parameters ());
396411
@@ -430,7 +445,7 @@ protected function buildActionPromise()
430445 call_user_func ([$ this ->action , 'form ' ]);
431446 }
432447
433- $ this ->addModalHtml ($ this -> modalId );
448+ $ this ->addModalHtml ();
434449
435450 return <<<SCRIPT
436451 var process = new Promise(function (resolve,reject) {
0 commit comments