Matt
Matt

Reputation: 2843

Symfony2 Form component - Adding fields from different Form Types

See the code example below:

public function buildForm(FormBuilder $builder, array $options)
{
    $builder->add('firstname');
    $builder->add('lastname');
    $builder->add('QualificationGradeOne'); // from Qualification Model
    // show some more user info
    $builder->add('address1');
    $builder->add('address2');
    $builder->add('QualificationGradeTwo'); // from Qualification Model
    /* ... */

This isnt my actual code. I've just shown it this way so that everyone understands my problem without knowing exactly the database structure etc of my application.

Does anyone know how to do this so that I can add one field of the Qualification model, then a few more User components, then adding a further few Qualification components. I've looked at creating a Qualification Form Type, however that returns back components all together and not individually.

Thanks in advance

Upvotes: 0

Views: 268

Answers (1)

Grug
Grug

Reputation: 1890

$builder->add('gradeone', new QualificationGradeOne());

Upvotes: 2

Related Questions