Symfony 3 - 结束表单块的最佳实践

I'm trying to learn how to build forms in symfony 3. Following some tutorials I have built a PersonType

class PersonType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {

        $builder->add('gender', ChoiceType::class, array('label' => 'Anrede', 'choices' => array('Herr' => 'Herr', 'Frau' => 'Frau'), 'attr' => array('class' => 'form-control')))
                ->add('title', TextType::class, array('label' => 'Titel', 'attr' => array('class' => 'form-control')))
                ->add('firstname', TextType::class, array('label' => 'Vorname', 'attr' => array('class' => 'form-control')))
                ->add('lastname', TextType::class, array('label' => 'Nachname', 'attr' => array('class' => 'form-control')))
                ->add('birthdate', DateType::class, array('label' => 'Geburtsdatum', 'attr' => array('class' => 'form-control')))

                ->add('street', TextType::class, array('label' => 'Straße', 'attr' => array('class' => 'form-control')))
                ->add('streetnumber', TextType::class, array('label' => 'Hausnummer', 'attr' => array('class' => 'form-control')))
                ->add('zip', TextType::class, array('label' => 'PLZ', 'attr' => array('class' => 'form-control')))
                ->add('city', TextType::class, array('label' => 'Stadt', 'attr' => array('class' => 'form-control')))

                ->add('email', TextType::class, array('label' => 'E-Mail', 'attr' => array('class' => 'form-control')));        
        }

    public function getName() {
        return 'person';
        }       

    }

And some other types.

In the controller I have

$person = new Person();
$form = $this->createForm(PersonType::class, $person);

My question now is, how do I now concat the PersonType to some other Types to get one Form out of it? And how do I then set the submit-button?

You cannot concatenate but you can include a subset of fields in several forms.

Here you have a nice example in the Symfony documentation :

http://symfony.com/doc/current/cookbook/form/inherit_data_option.html

Recap :

  • Create a form with your subfields, with the option 'inherit_data' => true.
  • Use it in another form as field.

First of all, please note how you add fields to PersonType form, because it will be exactly the same.

->add('email', TextType::class, array('label' => 'E-Mail', 'attr' => array('class' => 'form-control')));

What you do here is adding a subform TextType. It actually contains single field, but it's still a form.

The same way you can add PersonType to any other form. That would be something like:

->add('person', PersonType::class, array(/* some options if needed*/);

And how do I then set the submit-button?

As mentioned in Best Practices for Symfony Forms, I would suggest to add them in template, not to the form object.