I believe there is not a way to access the parent form data in any "clean" way.
However, it IS possible.
You will have to pass it as an option to the subform from the mainform.
Example:
Main form, how you will include subform:
$builder->add('sub', new SubType(), array('parent_data' => $builder->getData());
If your subtype is collection, it is a little bit different:
$builder->add('subs', 'collection', array('type' => new SubType(),
'options' => array('parent_data' => $builder->getData()))
);
Add this to subform:
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver
->setRequired(array('parent_data'));
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$parentData = $options['parent_data'];
... build subform
}
Please tell me if it works, I wrote it without testing, so we can fix any possible typos.