@@ -232,7 +232,7 @@ protected function jsExecute($return, Model\UserAction $action = null)
232232 } elseif ($ return instanceof Model) {
233233 $ msg = $ return ->isLoaded () ? $ this ->saveMsg : ($ action ->appliesTo === Model \UserAction::APPLIES_TO_SINGLE_RECORD ? $ this ->deleteMsg : $ this ->defaultMsg );
234234
235- return $ this ->jsModelReturn ($ action , $ msg );
235+ return $ this ->jsModelReturn ($ action , $ return , $ msg );
236236 }
237237
238238 return $ this ->getNotifier ($ this ->defaultMsg , $ action );
@@ -255,11 +255,11 @@ protected function getNotifier(string $msg = null, Model\UserAction $action = nu
255255 /**
256256 * Js expression return when action afterHook executor return a Model.
257257 */
258- protected function jsModelReturn (Model \UserAction $ action = null , string $ msg = 'Done! ' ): array
258+ protected function jsModelReturn (Model \UserAction $ action = null , Model $ returnEntity , string $ msg = 'Done! ' ): array
259259 {
260260 $ js = [];
261261 $ js [] = $ this ->getNotifier ($ msg , $ action );
262- if ($ action -> getModel ()-> isLoaded () && $ card = $ this ->findCard ($ action -> getModel () )) {
262+ if ($ returnEntity -> isLoaded () && $ card = $ this ->findCard ($ returnEntity )) {
263263 $ js [] = $ card ->jsReload ($ this ->getReloadArgs ());
264264 } else {
265265 $ js [] = $ this ->container ->jsReload ($ this ->getReloadArgs ());
@@ -281,10 +281,10 @@ protected function jsModelReturn(Model\UserAction $action = null, string $msg =
281281 *
282282 * @return mixed
283283 */
284- protected function findCard (Model $ model )
284+ protected function findCard (Model $ entity )
285285 {
286- $ mapResults = function ($ a ) use ($ model ) {
287- return $ a [$ model ->idField ];
286+ $ mapResults = function ($ a ) use ($ entity ) {
287+ return $ a [$ entity ->idField ];
288288 };
289289 $ deck = [];
290290 foreach ($ this ->cardHolder ->elements as $ element ) {
@@ -293,9 +293,9 @@ protected function findCard(Model $model)
293293 }
294294 }
295295
296- if (in_array ($ model ->getId (), array_map ($ mapResults , $ model -> export ([$ model ->idField ])), true )) {
296+ if (in_array ($ entity ->getId (), array_map ($ mapResults , $ entity -> getModel ()-> export ([$ entity ->idField ])), true )) {
297297 // might be in result set but not in deck, for example when adding a card.
298- return $ deck [$ model ->getId ()] ?? null ;
298+ return $ deck [$ entity ->getId ()] ?? null ;
299299 }
300300
301301 return null ;
0 commit comments