handleExtraData example

$form = $this->createForm(AddressFormType::class$address);
        $form->handleRequest($this->Request());

        if ($form->isSubmitted() && $form->isValid()) {
            if ($address->getId()) {
                $this->addressService->update($address);
            } else {
                $customer = $this->get(ModelManager::class)->find(Customer::class$userId);
                $this->addressService->create($address$customer);
            }

            $this->handleExtraData($extraData$address);

            $addressView = $this->get(ModelManager::class)->toArray($address);
            $addressView['country'] = $this->get(ModelManager::class)->toArray($address->getCountry());
            $addressView['state'] = $this->get(ModelManager::class)->toArray($address->getState());
            $addressView['attribute'] = $this->get(ModelManager::class)->toArray($address->getAttribute());
            $response['data'] = $addressView;
        } else {
            foreach ($form->getErrors(true) as $error) {
                $response['errors'][$error->getOrigin()->getName()] = $error->getMessage();
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.