Sonata admin - receive messages

I am learning symfony2 and sonata admin and have encountered several problems, and this is one of them.
I created an admin class that extends the sonata administrator and below will not work for me:

$this->getForm()->get('page')

or

$this->getRequest()->request->get('page')

I am trying to pass some hidden fields to configureFormFields, but I cannot access them using the above after the form has been submitted. I see an array of requests, but it get('page')returns null. In addition, the array of queries is multidimensional.

Any advice is appreciated.

A simple example of what I'm trying to do is given 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();  
}  
+4
source share
3 answers

, , , -:

$this->getForm()->get('subobject')->getData()
+2

. : https://groups.google.com/forum/#!topic/sonata-users/NS0mTAAHt7o

:

public function preUpdate($object)
{
    $uniqid = $this->getRequest()->query->get('uniqid');
    $formData = $this->getRequest()->request->get($uniqid);
    var_dump($formData);exit;
}

.

+1

, directy prepersist.

"" $?

$object->sub;

$this- > getRequest() symfony, , admin.

0

Source: https://habr.com/ru/post/1529018/


All Articles