2017-07-10 17 views
0

少し問題があります。主キーIDの値がありません

私は、これはデータベース enter image description here

と私のrealtionであり、これは私のエンティティであるAppBundle \エンティティ\ユーザー

に主キーidの値がありません。このエラーに

を取得しています

/** 
* @ORM\Entity 
* @ORM\Table(name="caller_machine") 
*/ 
class CallerMachine { 

/** 
* @ORM\GeneratedValue(strategy="AUTO") 
* @ORM\Id 
* @ORM\Column(type="integer") 
*/ 
private $id; 

/** 
* @ORM\Column(type="integer", nullable=true) 
*/ 
private $buttonNumber; 

/** 
* @ORM\Column(type="text", nullable=false) 
*/ 
private $linkToMusic; 

/** 
* @ORM\Column(type="text", nullable=true) 
*/ 
private $telephoneNumber; 

/** 
* @ORM\Column(type="text", nullable=true) 
*/ 
private $acceptRegulations; 

/** 
* @ORM\ManyToOne(
*  targetEntity = "AppBundle\Entity\CallerMachineVoice" 
*) 
* 
* @ORM\JoinColumn(
*  name = "number_id", 
*  referencedColumnName = "id", 
*  nullable = false 
*) 
*/ 
private $numberMachine; 

.......

/** 
* @ORM\Entity 
* @ORM\Table(name="user_name") 
*/ 
class User { 
    /** 
    * @ORM\Column(type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @ORM\Column(type="string", length = 20, unique = true) 
    */ 
    private $username; 

...........

/** 
* @ORM\Entity 
* @ORM\Table(name="call_back_machine") 
*/ 
class CallBackMachine { 

    /** 
    * @ORM\GeneratedValue(strategy="AUTO") 
    * @ORM\Id 
    * @ORM\Column(type="integer") 
    */ 
    private $id; 

    /** 
    * @ORM\Column(type="integer", nullable=true) 
    */ 
    private $buttonNumber; 

    /** 
    * @ORM\Column(type="text", nullable=false) 
    */ 
    private $linkToMusic; 

    /** 
    * @ORM\Column(type="text", nullable=true) 
    */ 
    private $telephoneNumber; 

    /** 
    * @ORM\Column(type="text", nullable=true) 
    */ 
    private $acceptRegulations; 


    /** 
    * @ORM\ManyToOne(
    *  targetEntity = "AppBundle\Entity\CallBackMachineVoice" 
    *) 
    * 
    * @ORM\JoinColumn(
    *  name = "number_id", 
    *  referencedColumnName = "id", 
    *  nullable = false 
    *) 
    */ 
    private $numberMachine; 

.......

/** 
* @ORM\Entity 
* @ORM\Table(name="call_back_machine_voice") 
*/ 
class CallBackMachineVoice { 
    /** 
    * @ORM\Column(type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @ORM\ManyToOne(
    *  targetEntity = "AppBundle\Entity\User" 
    *) 
    * 
    * @ORM\JoinColumn(
    *  name = "users_id", 
    *  referencedColumnName = "username", 
    *  nullable = false 
    *) 
    */ 
    private $user; 

    /** 
    * @ORM\Column(type="string") 
    */ 
    private $linkToMusic; 

... ............

/** 
* @ORM\Entity 
* @ORM\Table(name="caller_machine_voice") 
*/ 
class CallerMachineVoice { 
    /** 
    * @ORM\Column(type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @ORM\OneToOne(
    *  targetEntity = "AppBundle\Entity\User" 
    *) 
    * 
    * @ORM\JoinColumn(
    *  name = "users_id", 
    *  referencedColumnName = "username", 
    *  nullable = false 
    *) 
    */ 
    private $user; 

    /** 
    * @ORM\Column(type="string") 
    */ 
    private $linkToMusic; 

私はフォーム

を作成
public function buildForm(FormBuilderInterface $builder, array $options) { 
     $builder 
       ->add('numbermachine', EntityType::class, [ 
        'class' => 'AppBundle\Entity\CallerMachineVoice', 
        'choice_label' => 'user' 
       ]) 
       ->add('buttonnumber', IntegerType::class, [ 
        'label' => 'Podaj numer przycisku' 
       ]) 
       ->add('linktomusic', TextType::class,[ 
        'label' => 'Podaj link do muzyki' 
       ]) 
       ->add('telephonenumber', IntegerType::class, [ 
        'label' => 'Podaj numer przycisku' 
       ]) 
       ->add('acceptregulations', IntegerType::class, [ 
        'label' => 'Podaj numer przycisku' 
       ]) 
       ->add('submit', \Symfony\Component\Form\Extension\Core\Type\SubmitType::class, array(
        'label' => 'Zapisz' 
       )); 
    } 

私は問題がありますが、行を削除すると、numberMachine ''私のフォームが表示されます。私の問題はどこですか?私を助けて:)

顕在

は、おそらく私の問題は、このお試しくださいエンティティCallerMachineVoice

答えて

1

です:そして、ユーザーエンティティ__toStringマジックメソッドに定義

/** 
* @ORM\ManyToOne("User") 
* @ORM\JoinColumn(
*  name = "user_id", 
*  referencedColumnName = "id", 
*  nullable = false 
*) 
*/ 
private $user; 

をCallerMachineVoiceで

/** 
* @return string 
*/ 
public function __toString() 
{ 
    return $this->getUsername(); 
} 
+0

Thansk Strnm :) –

関連する問題