public function submit(FormEvent $event)
    {
        try{
            $form = $event->getForm();
            $parentForm = $form->getParent();
            $parentData = $parentForm->getData();

            // Edit case
            if ($parentData) {
                // First, we get the entity class
                $entityClass = get_class($parentData);

                $em = $this->doctrineService->getManagerForClass($entityClass);
                $repository = $em->getRepository('Gedmo\\Translatable\\Entity\\Translation');

                // Gets the translatable fields and their content
                $translatableFields = $this->getTranslatableFields($entityClass);
                $data = $event->getData();

                foreach ($this->localeList as $locale) {
                    if ($locale != $this->currentLocale) {
                        // Here we extract the field values from the submitted data
                        // Here type is useless, just used for getting the field
                        foreach ($translatableFields as $field => $type) {
                            // Here just translate the data
                            $repository->translate($parentData, $field, $locale, $data[$field."-".$locale] );
                        }
                    }
                }

            }
        } catch (\Exception $e) {
            // Case of a non entity object given to the parent form.
            // Unstranslatable case, throw exception.
            $secondException = new \Exception("The object that was given to the form you wanted to translate isn't an entity one. Untranslatable in this case.", $e->getCode(), $e);
            throw $secondException;
        }
    }
public function submit(FormEvent $event)
    {
        try{
            $form = $event->getForm();
            $parentForm = $form->getParent();
            $parentData = $parentForm->getData();

            // Edit case
            if ($parentData) {
                // First, we get the entity class
                $entityClass = get_class($parentData);

                $em = $this->doctrineService->getManagerForClass($entityClass);
                $repository = $em->getRepository('Gedmo\\Translatable\\Entity\\Translation');

                // Gets the translatable fields and their content
                $translatableFields = $this->getTranslatableFields($entityClass);
                $data = $event->getData();

                foreach ($this->localeList as $locale) {
                    if ($locale != $this->currentLocale) {
                        // Here we extract the field values from the submitted data
                        // Here type is useless, just used for getting the field
                        foreach ($translatableFields as $field => $type) {
                            // Here just translate the data
                            $repository->translate($parentData, $field, $locale, $data[$field."-".$locale] );
                        }
                    }
                }

            }
        } catch (\Exception $e) {
            // Case of a non entity object given to the parent form.
            // Unstranslatable case, throw exception.
            $secondException = new \Exception("The object that was given to the form you wanted to translate isn't an entity one. Untranslatable in this case.", $e->getCode(), $e);
            throw $secondException;
        }
    }
public function submit ( FormEvent $ event ) { try { $ form = $ event -> getForm ( ) ; $ parentForm = $ form -> getParent ( ) ; $ parentData = $ parentForm -> getData ( ) ; // Edit case if ( $ parentData ) { // First, we get the entity class $ entityClass = get_class ( $ parentData ) ; $ em = $ this -> doctrineService -> getManagerForClass ( $ entityClass ) ; $ repository = $ em -> getRepository ( 'Gedmo\\Translatable\\Entity\\Translation' ) ; // Gets the translatable fields and their content $ translatableFields = $ this -> getTranslatableFields ( $ entityClass ) ; $ data = $ event -> getData ( ) ; foreach ( $ this -> localeList as $ locale ) { if ( $ locale != $ this -> currentLocale ) { // Here we extract the field values from the submitted data // Here type is useless, just used for getting the field foreach ( $ translatableFields as $ field => $ type ) { // Here just translate the data $ repository -> translate ( $ parentData , $ field , $ locale , $ data [ $ field . "-" . $ locale ] ) ; } } } } } catch ( \ Exception $ e ) { // Case of a non entity object given to the parent form. // Unstranslatable case, throw exception. $ secondException = new \ Exception ( "The object that was given to the form you wanted to translate isn't an entity one. Untranslatable in this case." , $ e -> getCode ( ) , $ e ) ; throw $ secondException ; } }
Submit form handling

@param FormEvent $event
@throws \Exception in case of the Susbcriber was set on a non entity form
Submit form handling