idipous
idipous

Reputation: 2910

Symfony2 How is formBuilder function called?

Hi I am new to symfony2 and while I was reading the documentation I could not figure out how

public function buildForm(FormBuilderInterface $builder, array $options) is called from within the TaskType class (in the example) using the helper createForm() in the controller.

I looked into the FormFactory.php file and I could see how the function getName() is called but nowhere the buildForm().

I know it is not really important in order to code a form but I would like to know so as to get a better grasp of what I am doing and why.

Thanks, idipous

Upvotes: 0

Views: 214

Answers (1)

Luke
Luke

Reputation: 3353

In Symfony2.0

Around line 280 in \Symfony\Component\Form\FormFactory there is the line:

$type->buildForm($builder, $options);

and a little lower is:

$typeExtension->buildForm($builder, $options);

In Symfony2.1

Around line 124 \Symfony\Component\Form\ResolvedFormType in function createBuilder:

$this->buildForm($builder, $options);

and a number of other places in this file.

This is used in \Symfony\Component\Form\FormFactory on line 165 in function addType:

$this->registry->addType($this->resolvedTypeFactory->createResolvedType(
        $type,
        array(),
        $parentType ? $this->registry->getType($parentType) : null
    ));

Upvotes: 1

Related Questions