有这个......
$builder->add('city', 'entity', array(
'class' => '..\Entity\City',
'translation_domain' => $this->translation_domain,
'required' => true,
'expanded' => true,
'invalid_message' => 'form.error.city',
'empty_value' => 'form.placeholder.city',
'query_builder' => function (...\Repository\CityRepository $repository) {
return $repository->get(array(
'enabled' => true,
'locale' => $this->container->get('poisk_raboty.helper.main')->getLocale(),
), true);
},
'attr' => array(
'data-search' => 2,
'data-placeholder' => $this->container->get('translator')->trans('form.placeholder.city', array(), $this->translation_domain),
),
))
;
如何在表单构建器中获取城市,其中一个元素必须像城市一样?