Reputation: 9552
When I define a Form Type for an arbitrary Entity, let's say User
, I can then add a UserFormType class as follow,
class UserFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
// ...
$builder->add('email', 'text');
}
}
What if I want to define another form type for the User:
Upvotes: 0
Views: 78
Reputation: 4468
You can define as many Types as you need for each entity.
If I need more than one Type, I usually have the "standard" entitynameType and for the other ones I attach some keyword related to the place I am using it. For example if one form is only for update the status UserStatusType.
You have to use another class because you are extending AbstractType and the method that build the form must be buildForm.
If you need to adapt your form depending the kind of user you have you can use an event listener http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html
Upvotes: 2