Updating scaffold views with new FormHelper and URL code

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4111 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-12-20 21:41:42 +00:00
parent 6e3f0c8f1c
commit ccf52fa20d
4 changed files with 20 additions and 24 deletions

View file

@ -26,12 +26,12 @@
?>
<h2>New <?php echo $humanSingularName?></h2>
<?php
echo $form->create($modelClass, array('action' => 'create'));
echo $form->displayFields($fieldNames);
echo $form->generateSubmitDiv('Add'); ?>
echo $form->create($modelClass);
echo $form->inputs($fieldNames);
echo $form->submit('Add'); ?>
</form>
<ul class='actions'>
<?php echo "<li>".$html->link('List '.$humanPluralName, $path . $viewPath.'/index/')."</li>"; ?>
<?php echo "<li>".$html->link('List '.$humanPluralName, array('action' => 'index'))."</li>"; ?>
<?php
foreach($fieldNames as $field => $value) {
if(isset($value['foreignKey'])) {

View file

@ -27,25 +27,21 @@ $modelObj =& ClassRegistry::getObject($modelKey);
?>
<h2><?php echo $formName.' '.$humanSingularName;?></h2>
<?php
if($formName == 'Edit') {
echo $form->create($modelClass, array('action' => 'update'));
} else {
echo $form->create($modelClass, array('action' => 'create'));
}
echo $form->displayFields($fieldNames);
echo $form->generateSubmitDiv('Save'); ?>
echo $form->create($modelClass);
echo $form->inputs($fieldNames);
echo $form->submit('Save'); ?>
</form>
<ul class='actions'>
<?php
if($formName == 'Edit') {
echo "<li>".$html->link('Delete '.$humanSingularName, $path . $viewPath.'/delete/'.$data[$modelClass][$primaryKey], null, 'Are you sure you want to delete '.$data[$modelClass][$displayField])."</li>";
echo "<li>".$html->link('Delete '.$humanSingularName, array('action' => 'delete', $data[$modelClass][$primaryKey]), null, 'Are you sure you want to delete '.$data[$modelClass][$displayField])."</li>";
}
echo "<li>".$html->link('List '.$humanPluralName, $path . $viewPath.'/index')."</li>";
echo "<li>".$html->link('List '.$humanPluralName, array('action' => 'index'))."</li>";
if($formName == 'Edit') {
foreach($fieldNames as $field => $value) {
if(isset($value['foreignKey'])) {
echo "<li>".$html->link( "View ".Inflector::humanize($value['controller']), $path . Inflector::underscore($value['controller'])."/index")."</li>";
echo "<li>".$html->link( "Add ".Inflector::humanize($value['modelKey']), $path . Inflector::underscore($value['controller'])."/add/")."</li>";
echo '<li>' . $html->link('View ' . Inflector::humanize($value['controller']), array('action' => 'index')) . '</li>';
echo '<li>' . $html->link('Add ' . Inflector::humanize($value['modelKey']), array('action' => 'add')) . '</li>';
}
}
}?>

View file

@ -74,7 +74,7 @@ if(is_array($data)) {
<?php $id = $row[$modelClass][$modelObj->primaryKey]; ?>
<?php echo $html->link('View', array('action' => 'view', $id)) ?>
<?php echo $html->link('Edit', array('action' => 'edit', $id)) ?>
<?php echo $html->link('Delete', array('action' => 'view', $id), null, 'Are you sure you want to delete id '.$id.' ?') ?>
<?php echo $html->link('Delete', array('action' => 'delete', $id), null, 'Are you sure you want to delete id '.$id.' ?') ?>
</td>
</tr>
<?php

View file

@ -58,14 +58,14 @@ foreach($fieldNames as $field => $value) {
</dl>
<ul class='actions'>
<?php
echo "<li>".$html->link('Edit '.$humanSingularName, $path . $viewPath.'/edit/'.$data[$modelClass][$modelObj->primaryKey])."</li>";
echo "<li>".$html->link('Delete '.$humanSingularName, $path . $viewPath.'/delete/'.$data[$modelClass][$modelObj->primaryKey], null, 'Are you sure you want to delete id '.$data[$modelClass][$modelObj->primaryKey].' ?')."</li>";
echo "<li>".$html->link('List '.$humanPluralName, $path . $viewPath.'/index')."</li>";
echo "<li>".$html->link('New '.$humanSingularName, $path . $viewPath.'/add')."</li>";
echo '<li>' . $html->link('Edit '.$humanSingularName, array('action' => 'edit', $data[$modelClass][$modelObj->primaryKey])) . '</li>';
echo '<li>' . $html->link('Delete '.$humanSingularName, array('action' => 'delete', $data[$modelClass][$modelObj->primaryKey]), null, 'Are you sure you want to delete id '.$data[$modelClass][$modelObj->primaryKey].' ?') . '</li>';
echo '<li>' . $html->link('List '.$humanPluralName, array('action' => 'index')) . '</li>';
echo '<li>' . $html->link('New '.$humanSingularName, array('action' => 'add')) . '</li>';
foreach( $fieldNames as $field => $value ) {
if( isset( $value['foreignKey'] ) ) {
echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), $path . $value['controller'] ."/index/")."</li>";
foreach($fieldNames as $field => $value) {
if(isset($value['foreignKey'])) {
echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), array('controller' => $value['controller'], action => 'index')) . '</li>';
echo "<li>".$html->link( "Add ".Inflector::humanize($value['controller']), $path . $value['controller'] ."/add/")."</li>";
}
}?>
@ -157,6 +157,6 @@ foreach($relations as $associationName => $relation) {
}?>
</table>
<ul class="actions">
<?php echo "<li>".$html->link('New '.Inflector::humanize($associationName), $path . $otherControllerPath ."/add/")."</li>";?>
<?php echo "<li>".$html->link('New '.Inflector::humanize($associationName), $path . $otherControllerPath . '/add') . '</li>'; ?>
</ul></div>
<?php }?>