Browse Source

Set the primary entity to the view on add/edit forms.

mark_story 12 years ago
parent
commit
45c532ea62

+ 4 - 8
src/Console/Templates/default/actions/controller_actions.ctp

@@ -48,7 +48,7 @@ foreach ($modelObj->associations()->type('BelongsTo') as $assoc) {
 		$this->set('<?= $singularName; ?>', $<?= $singularName; ?>);
 	}
 
-<?php $compact = []; ?>
+<?php $compact = ["'" . $singularName . "'"]; ?>
 /**
  * Add method
  *
@@ -74,13 +74,11 @@ foreach ($modelObj->associations()->type('BelongsTo') as $assoc) {
 			$compact[] = "'{$otherPlural}'";
 		endforeach;
 	endforeach;
-	if (!empty($compact)):
-		echo "\t\t\$this->set(compact(" . join(', ', $compact) . "));\n";
-	endif;
+	echo "\t\t\$this->set(compact(" . join(', ', $compact) . "));\n";
 ?>
 	}
 
-<?php $compact = []; ?>
+<?php $compact = ["'" . $singularName . "'"]; ?>
 /**
  * Edit method
  *
@@ -108,9 +106,7 @@ foreach ($modelObj->associations()->type('BelongsTo') as $assoc) {
 				$compact[] = "'{$otherPlural}'";
 			endforeach;
 		endforeach;
-		if (!empty($compact)):
-			echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n";
-		endif;
+		echo "\t\t\$this->set(compact(" . join(', ', $compact) . "));\n";
 	?>
 	}
 

+ 2 - 2
tests/bake_compare/Controller/Actions.ctp

@@ -43,7 +43,7 @@
 		}
 		$bakeUsers = $this->BakeArticles->association('BakeUsers')->find('list');
 		$bakeTags = $this->BakeArticles->association('BakeTags')->find('list');
-		$this->set(compact('bakeUsers', 'bakeTags'));
+		$this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags'));
 	}
 
 /**
@@ -66,7 +66,7 @@
 		}
 		$bakeUsers = $this->BakeArticles->association('BakeUsers')->find('list');
 		$bakeTags = $this->BakeArticles->association('BakeTags')->find('list');
-		$this->set(compact('bakeUsers', 'bakeTags'));
+		$this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags'));
 	}
 
 /**