Changeset 263

Show
Ignore:
Timestamp:
06/24/07 08:10:24 (1 year ago)
Author:
bermiferrer
Message:

Fixing bug in the scaffold generator when using a model with a different name.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/script/generators/scaffold/templates/controller.php

    r230 r263  
    66<?php  
    77    if($model_name != $controller_name){ // if equal will be handled by the Akelos directly 
    8         echo "    var \$models = '$singular_name';"; 
     8        echo "    var \$models = '$singular_name';\n\n"; 
    99    } 
    1010?> 
     
    4141        } 
    4242    } 
     43    <?php  if($model_name != $controller_name){ ?> 
     44 
     45    function edit() 
     46    { 
     47        if(!empty($this->params['id'])){ 
     48            if(empty($this-><?php echo $singular_name?>->id) || $this-><?php echo $singular_name?>->id != $this->params['id']){ 
     49                $this-><?php echo $singular_name?> =& $this-><?php echo $model_name?>->find($this->params['id']); 
     50            } 
     51        }else{ 
     52            $this->redirectToAction('listing'); 
     53        } 
     54 
     55        if(!empty($this->params['<?php echo $singular_name?>'])){ 
     56            $this-><?php echo $singular_name?>->setAttributes($this->params['<?php echo $singular_name?>']); 
     57            if($this->Request->isPost() && $this-><?php echo $singular_name?>->save()){ 
     58                $this->flash['notice'] = $this->t('<?php echo $model_name?> was successfully updated.'); 
     59                $this->redirectTo(array('action' => 'show', 'id' => $this-><?php echo $singular_name?>->getId())); 
     60            } 
     61        } 
     62    } 
     63    <?php } else { ?> 
    4364 
    4465    function edit() 
     
    4869        } 
    4970        if(!empty($this->params['<?php echo $singular_name?>']) && !empty($this->params['id'])){ 
    50             <?php  
    51             if($model_name != $controller_name){ // if equal will be handled by the Akelos directly 
    52                 ?>if(empty($this-><?php echo $singular_name?>->id) || $this-><?php echo $singular_name?>->id != $this->params['id']){ 
    53                     $this-><?php echo $singular_name?> =& $this-><?php echo $model_name?>->find($this->params['id']); 
    54                 }<?php 
    55             } 
    56             ?> 
    5771            $this-><?php echo $singular_name?>->setAttributes($this->params['<?php echo $singular_name?>']); 
    5872            if($this->Request->isPost() && $this-><?php echo $singular_name?>->save()){ 
     
    6276        } 
    6377    } 
    64  
     78    <?php } ?> 
     79     
    6580    function destroy() 
    6681    {