I've got 3 entities: - overriden User - Address - Company
User Entity got entity fields Address and Company.
Now I'm trying to build User Registration Form using as well fields from Address and Company entities. The problem is - I have no idea how to proceed with this.
I was trying to do sth like this:
$this->addCommonFields($builder);
$builder
->add('company', 'entity', array(
'label' => 'street',
'class' => 'AcmePsoBundle:Company',
'property' => 'street',
));
but then I receive dropdown list and it supposed to be textfield.
@Edit: Should I use DataTransformer?
You should create new form type for your AcmePsoBundle:Company entity, and use it as:
$builder->add('company', new YourCompanyFormType());
YourCompanyFormType.php example:
class YourCompanyFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'street',
'text'
);
}
And don't forget to set empty Company to new user entity $user->setCompany(new Company()); before form.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.