开发者

getting two column with relation

i learn Symfony and Doctrine with Jobeet. I would like add aeveral modifications. default is: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/03

JobeetCategory:
  actAs: { Timestampable: ~ }
  columns:
    name: { type: string(255), notnull: true, unique: true }

JobeetJob:
  actAs: { Timestampable: ~ }
  columns:
    category_id:  { type: integer, notnull: true }
 (...)
  relations:
    JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: JobeetJobs } 

and if i go to form (create new) i have: http://www.symfony-project.org/images/jobeet/1_4/03/job.png

Category id - choice list

//BaseJobeetJobForm.class.php :

 'category_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('JobeetCategory'), 'add_empty' => false)),

//sfFormDoctrine.class.php :

  protected function getRelatedModelName($alias)
  {
    $table = Doctrine_Core::getTable($this->getModelName());

    if (!$table->hasRelation($alias))
    {
      throw new InvalidArgumentException(sprintf('The "%s" model has to "%s" relation.', $this->getModelName(), $alias));
    }

    $relation = $table->getRelation($alias);

    return $relation['class'];
  }

how can I do something like:

JobeetCategory:
  actAs: { Timestampable: ~ }
  columns:
    name: { type: string(255), notnull: true, unique: true }
    nametwo: { type: string(255), notnull: true, unique: true }

JobeetJob:
  actAs: { Timestampable: ~ }
  columns:
    category_id:  { type: integer, notnull: true }
    nametwo_id:  { type: integer, notnull: true }
 (...)
  relations:
        JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: Jo开发者_开发技巧beetJobs } 
JobeetCategory: { onDelete: CASCADE, local: nametwo_id, foreign: id, foreignAlias: JobeetJobsTwo } 

how can i show in form "nametwo"? i will two list choices (category_id (already) and nametwo_id: )


You want to setup two distinct relation between jobeetjob and jobeetcategory.
You have to name distinctly the relation, like this :

    JobeetJob:   
     actAs: { Timestampable: ~ }  
     columns:
       category_id:  { type: integer, notnull: true }
       nametwo_id:  { type: integer, notnull: true }  (...)   
     relations:
       JobeetCategoryOne: 
         class: JobeetCategory
         onDelete: CASCADE
         local: category_id
         foreign: id
         foreignAlias: JobeetJobs  
       JobeetCategoryTwo: 
         class: JobeetCategory
         onDelete: CASCADE
         local: nametwo_id, foreign: id,
         foreignAlias: JobeetJobsTwo 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜