Php Symfony2设置实体类型的选定值

Php Symfony2设置实体类型的选定值,php,symfony,symfony-forms,Php,Symfony,Symfony Forms,这可能是个愚蠢的问题,但我被卡住了。在我的Symfony2应用程序中,我有以下字段: public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('match_team1','entity', array( 'class' => 'MyAppBundle:Team', 'expanded

这可能是个愚蠢的问题,但我被卡住了。在我的Symfony2应用程序中,我有以下字段:

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('match_team1','entity', array(
            'class'     => 'MyAppBundle:Team',
            'expanded'  => false,
            'multiple'  => false,
            'label'     => 'Team 1',
            'mapped'    => true,
            'property'  => 'name'

        ));
}
比赛课

class Match
{


/**
 * @var integer
 */
private $id;


/**
 * @var integer
 */
private $match_number;

/**
 * @var string
 */
private $match_type;

/**
 * @var \DateTime
 */
private $match_date;

/**
 * @var string
 */
private $match_status;

/**
 * @var string
 */
private $match_team1;

 /**
 * Set matchTeam1
 *
 * @param string $matchTeam1
 *
 * @return Match
 */
public function setMatchTeam1($matchTeam1)
{
    $this->match_team1 = $matchTeam1;

    return $this;
}

/**
 * Get matchTeam1
 *
 * @return string
 */
public function getMatchTeam1()
{
    return $this->match_team1;
}
编辑功能:

private function createEditForm(Match $entity)
{
    $form = $this->createForm(new MatchType(), $entity, array(
        'action' => $this->generateUrl('match_update', array('id' =>     $entity->getId())),
        'method' => 'PUT',
    ));


    $form->add('submit', 'submit', array('label' => 'Update'));

    return $form;
}

但当我更新表单时,下拉列表中的选定值不会保留。在数据库中我可以看到条目,但在表单中它没有显示。有人能帮我设置所选的值吗?

您不需要向我们显示您的实体(用作该表单的数据)您是指团队实体吗?我在Match实体中使用此表单。在match Entity中,我在您的match Entity中添加了具有属性名称how us how look$match\u team1条令配置的团队实体。我已添加了match Entity“在数据库中,我可以看到条目”-这是否意味着match\u team1\u id正在数据库表中设置?或者它是空的?