Development

Changeset 9937

You must first sign up to be able to contribute.

Changeset 9937

Show
Ignore:
Timestamp:
06/27/08 17:23:22 (3 months ago)
Author:
pmacadden
Message:

added one-to-many foreign_class auto setting feature (nesting, rest)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfAdvancedAdminGeneratorPlugin/branches/pmacadden/data/generator/sfAdvancedAdmin/default/template/actions/actions.class.php

    r9935 r9937  
    1414  public function preExecute() 
    1515  { 
     16<?php if ($fc = $this->getParameterValue('foreign_class', '')): ?> 
     17    $this->foreign_class = $this->getUser()->getAttribute('<?php echo sfInflector::underscore($fc) ?>'); 
     18    $this->forward404Unless($this->foreign_class); 
     19<?php endif ?> 
    1620    $this->maps = $this->getMaps(); 
    1721  } 
     
    8387<?php else: ?>     
    8488    $this-><?php echo $this->getSingularName() ?> = new <?php echo $this->getClassName() ?>(); 
     89<?php if ($fc = $this->getParameterValue('foreign_class', '')): ?> 
     90    $this-><?php echo $this->getSingularName() ?>->set<?php echo sfInflector::camelize($fc) ?>($this->foreign_class); 
     91<?php endif ?> 
    8592 
    8693    if ($this->getRequest()->getMethod() == sfRequest::POST) 
     
    103110  { 
    104111    $this-><?php echo $this->getSingularName() ?> = $this->get<?php echo $this->getClassName() ?>OrCreate(); 
     112<?php if (null === $this->getParameterValue('create')): ?> 
     113<?php if ($fc = $this->getParameterValue('foreign_class', '')): ?> 
     114    $this-><?php echo $this->getSingularName() ?>->set<?php echo sfInflector::camelize($fc) ?>($this->foreign_class); 
     115<?php endif ?> 
     116<?php endif ?> 
    105117 
    106118    if ($this->getRequest()->getMethod() == sfRequest::POST) 
     
    535547<?php endforeach; ?> 
    536548<?php endif; ?> 
     549<?php if ($fc = $this->getParameterValue('foreign_class', '')): ?> 
     550    $c->add(<?php echo $this->getPeerClassName() ?>::<?php echo strtoupper(sfInflector::underscore($fc)) ?>_ID, $this->foreign_class->getId()); 
     551<?php endif ?> 
    537552  } 
    538553 
  • plugins/sfAdvancedAdminGeneratorPlugin/branches/pmacadden/data/generator/sfAdvancedAdmin/default/template/templates/_create_form.php

    r9935 r9937  
    4545<?php $hides = $this->getParameterValue('create.hide', array()) ?> 
    4646<?php foreach ($this->getColumns('create.display', $category) as $name => $column): ?> 
     47<?php if (!$column->isForeignKey() && $column->getPhpName() != $this->getParameterValue('foreign_class').'Id'): ?> 
    4748<?php if (in_array($column->getName(), $hides)) continue ?> 
    4849<?php if ($column->isPrimaryKey()) continue ?> 
     
    6566    [?php endif; ?] 
    6667<?php endif; ?> 
     68<?php endif ?> 
    6769 
    6870<?php endforeach; ?> 
  • plugins/sfAdvancedAdminGeneratorPlugin/branches/pmacadden/data/generator/sfAdvancedAdmin/default/template/templates/_edit_form.php

    r9935 r9937  
    4545<?php $hides = $this->getParameterValue('edit.hide', array()) ?> 
    4646<?php foreach ($this->getColumns('edit.display', $category) as $name => $column): ?> 
     47<?php if (!$column->isForeignKey() && $column->getPhpName() != $this->getParameterValue('foreign_class').'Id'): ?> 
    4748<?php if (in_array($column->getName(), $hides)) continue ?> 
    4849<?php if ($column->isPrimaryKey()) continue ?> 
     
    6566    [?php endif; ?] 
    6667<?php endif; ?> 
     68<?php endif ?> 
    6769 
    6870<?php endforeach; ?>