From 08f8b0109bb13c6e631798ece3bb31179addc395 Mon Sep 17 00:00:00 2001 From: Elias Luhr Date: Thu, 3 Sep 2020 15:58:49 +0200 Subject: [PATCH] Fixed pivot url creating in crud view template --- src/generators/crud/default/views/view.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/generators/crud/default/views/view.php b/src/generators/crud/default/views/view.php index 97ddc341..14f6d92a 100644 --- a/src/generators/crud/default/views/view.php +++ b/src/generators/crud/default/views/view.php @@ -180,15 +180,24 @@ ['class'=>'btn text-muted btn-xs'] ) ?>\n"; // TODO: support multiple PKs - echo " via !== null) { + $url = "['".$generator->createRelationRoute($relation, 'create')."']"; + } else { + $url = "['".$generator->createRelationRoute($relation, 'create')."', '". + Inflector::id2camel($generator->generateRelationTo($relation), + '-', + true)."' => ['".key($relation->link)."' => \$model->".$model->primaryKey()[0]."]]"; + } + + echo " ' . ".$generator->generateString('New')." . ' ". - Inflector::singularize(Inflector::camel2words($name))."', - ['".$generator->createRelationRoute($relation, 'create')."', '". - Inflector::id2camel($generator->generateRelationTo($relation), - '-', - true)."' => ['".key($relation->link)."' => \$model->".$model->primaryKey()[0]."]], + Inflector::singularize(Inflector::camel2words($name))."', + {$url}, ['class'=>'btn btn-success btn-xs'] ); ?>\n"; + echo $addButton; echo "\n\n"; #
\n";