Einträge in Selectboxen einer foreignTable filtern (z.B. nach creator):

schema.yml:

propel: 
project: 
_attributes: { phpName: Project } 
id: 
creator_id: { type: integer, foreignTable: creator foreignReference: id, required: true, onDelete: cascade } 
name: { type: VARCHAR, size: 255, required: true } 
description: { type: VARCHAR, size: 255, required: true } 
...

/lib/model/ProjectPeer.php:

class ProjectPeer extends BaseProjectPeer 
{
  public static function getCreatorfiltered() {
    $c = new Criteria(); 
    $c->add(ProjectPeer::CREATOR_ID, sfContext::getInstance()->getUser()->getGuardUser()->getId()); //oder Creator ID 
  } 
  return ProjectPeer::doSelect($c); 
} 

generator.yml:

... 
fields: 
project_id: 
params: 
name: 
Project peer_method: getCreatorfiltered

gepostet am 03.09.2008 von Julian Stricker (Google+) Tags: php programmieren symfony