2011-08-30 2 views
0

에서 값을 얻을 : 내가 교리와 테이블이 현재 테이블

Name: 
    columns: 
    name_id: { type: integer(11), primary: true, autoincrement: true } 
    name_name: { type: string(65)} 
    parent_name_id: { type: integer(11) } 

내가 name_id.error가 함께 선택 입력 parent_name_id 목록에 원하는 이름을 편집하는 경우

는, 이전했다. 내가 사용하고 싶습니다 :

NameTable.class.php :

static public $name = array(
    'full-time' => 'Full time', // foreach ??? 
    'part-time' => 'Part time', // ???? 
    'freelance' => 'Freelance' // ???? 
); 

    public function getName() 
    { 
    return self::$name; 
    } 

$this->widgetSchema['parent_name_id'] = new sfWidgetFormChoice(array(
    'choices' => Doctrine::getTable('Name')->getName(), 
    'expanded' => true, 
)); 

하지만 어떻게 내가 모델이 생성 할 수 있습니까?

답변

1
Name: 
    columns: 
    name_id: { type: integer(11), primary: true, autoincrement: true } 
    name_name: { type: string(65)} 
    parent_name_id: { type: integer(11) } 
  1. 왜 name_name? 그것은 잘 당신이 만드는 것보다 이름 : 위해 이름을 변경합니다 :

$의 PHP 심포니의 교리 : 구축 --all - 그리고 부하 --no-확인

에서 당신은 sfWidgetFormDoctrineChoice을 사용할 수 있습니다/lib 디렉토리/모델/교리/기지 BaseName.class.php 당신은 예를

* @method string    getName()    Returns the current record's "name" value 

를 들어, 생성 된 모든 방법을 볼 수 있습니다 예 :

$this->widgetSchema['parent_name_id'] = new sfWidgetFormDoctrineChoice('model' => 'Name', 'add_empty' => false, 'multiple' => false);