【发布时间】:2015-10-27 00:10:54
【问题描述】:
我有 symfony 项目。我有实体开发人员和字段国家和城市。在我想要创建的表格 - 选择该国时,它出现在城市(这个国家城市),如果开发人员有IP - 可以通过ip来判断。我如何做到这一点,也许是捆绑或 lib?帮助
class Developer extends CustomUser
{
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=255, unique=false, nullable=true)
* @Assert\Length(min=3, max=255)
*/
protected $email;
/**
* @var string
*
* @ORM\Column(name="country", type="string", length=255, nullable=true)
*/
private $country;
/**
* @var string
*
* @ORM\Column(name="location", type="string", length=255, nullable=true)
*/
private $location;
和形式
class DeveloperPersonalInformationType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstname', null, array('label' => 'First Name', 'max_length' => 255, 'required' => false))
->add('lastname', null, array('label' => 'Last Name', 'max_length' => 255, 'required' => false))
->add('email', null, array('label' => 'Email', 'max_length' => 255, 'required' => false))
->add('country', 'choice', array('label' => 'Country', 'max_length' => 255, 'required' => false,
'choices' => $this->getCountries()))
->add('location', 'cities', array('label' => 'Location','required' => false, 'mapped' => true, 'attr' => array('placeholder' => 'Select Location', 'class'=>'cities') ))
【问题讨论】:
-
认真的吗?我们需要moooore.....mattgemmell.com/what-have-you-tried
-
我找到了解决这个问题的方法,现在我有了实体和表单,如果需要,我可以更改结构 mu 实体。但也许会被捆绑完成这项任务
标签: php forms symfony doctrine-orm