Browse Source

Not showing binary columns in any baked templates, fixing tests

Jose Lorenzo Rodriguez 11 years ago
parent
commit
ab13ef8ccc

+ 4 - 0
src/Template/Bake/default/views/form.ctp

@@ -14,6 +14,10 @@
  */
 use Cake\Utility\Inflector;
 
+$fields = collection($fields)
+	->filter(function($field) use ($schema) {
+		return $schema->columnType($field) !== 'binary';
+	});
 ?>
 <div class="actions columns large-2 medium-3">
 	<h3><?= "<?= __('Actions') ?>" ?></h3>

+ 4 - 1
src/Template/Bake/default/views/view.ctp

@@ -30,6 +30,9 @@ $associationFields = collection($fields)
 	}, []);
 
 $groupedFields = collection($fields)
+	->filter(function($field) use ($schema) {
+		return $schema->columnType($field) !== 'binary';
+	})
 	->groupBy(function($field) use ($schema, $associationFields) {
 		$type = $schema->columnType($field);
 		if (isset($associationFields[$field])) {
@@ -53,7 +56,7 @@ $groupedFields += ['number' => [], 'string' => [], 'boolean' => [], 'date' => []
 <?php
 	$pk = "\${$singularVar}->{$primaryKey[0]}";
 
-	echo "\t\t<li><?= \$this->Html->link(__('Edit " . $singularHumanName ."'), ['action' => 'edit', {$pk}]) ?> </li>\n";
+	echo "\t\t<li><?= \$this->Html->link(__('Edit " . $singularHumanName . "'), ['action' => 'edit', {$pk}]) ?> </li>\n";
 	echo "\t\t<li><?= \$this->Form->postLink(__('Delete " . $singularHumanName . "'), ['action' => 'delete', {$pk}], ['confirm' => __('Are you sure you want to delete # %s?', {$pk})]) ?> </li>\n";
 	echo "\t\t<li><?= \$this->Html->link(__('List " . $pluralHumanName . "'), ['action' => 'index']) ?> </li>\n";
 	echo "\t\t<li><?= \$this->Html->link(__('New " . $singularHumanName . "'), ['action' => 'add']) ?> </li>\n";

+ 2 - 2
tests/TestCase/Shell/Task/ViewTaskTest.php

@@ -289,7 +289,7 @@ class ViewTaskTest extends TestCase {
 	public function testGetContent() {
 		$vars = array(
 			'modelClass' => 'TestViewModel',
-			'schema' => [],
+			'schema' => TableRegistry::get('ViewTaskComments')->schema(),
 			'primaryKey' => ['id'],
 			'displayField' => 'name',
 			'singularVar' => 'testViewModel',
@@ -320,7 +320,7 @@ class ViewTaskTest extends TestCase {
 	public function testGetContentWithRoutingPrefix() {
 		$vars = array(
 			'modelClass' => 'TestViewModel',
-			'schema' => [],
+			'schema' => TableRegistry::get('ViewTaskComments')->schema(),
 			'primaryKey' => ['id'],
 			'displayField' => 'name',
 			'singularVar' => 'testViewModel',