I'm learning symfony2 and sonata admin and came across few problems and this is one of them.
I've created an admin class which extends sonata admin and the below wouldn't work for me:
$this->getForm()->get('page')
or
$this->getRequest()->request->get('page')
I'm trying to pass some hidden fields in the configureFormFields
but I can't access them using the above after the form has been submitted. I can see the request array but get('page')
returns null. Also, the request array is multidimensional.
Any advice appreciated.
Simple example of what I'm trying to do is below:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('title')
->add(
'subobject',
'hidden',
array(
'mapped' => false,
'data' => 'sub'
)
)
;
}
public function prePersist($object)
{
$subobject_request = $this->getRequest()->request->get('subobject');
print_r($subobject_request); //is null
die();
}