Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trouble making the profile Edit work #57

Open
HelpfulMan opened this issue Apr 11, 2014 · 10 comments
Open

trouble making the profile Edit work #57

HelpfulMan opened this issue Apr 11, 2014 · 10 comments

Comments

@HelpfulMan
Copy link

hi all,
I'm stuck and not solving the problem. I have correctly configured PUGXMultiUserBundle and I just need to make the profile Edit work of my class client work plz here it's my class

@HelpfulMan
Copy link
Author

id; } /** - Set nomClient * - @param string $nomClient - @return Client */ public function setNomClient($nomClient) { $this->nomClient = $nomClient; return $this; } /** - Get nomClient * - @return string */ public function getNomClient() { return $this->nomClient; } /** - Set prenomClient * - @param string $prenomClient - @return Client */ public function setPrenomClient($prenomClient) { $this->prenomClient = $prenomClient; return $this; } /** - Get prenomClient * - @return string */ public function getPrenomClient() { return $this->prenomClient; } /** - Set adresseLivraison * - @param string $adresseLivraison - @return Client */ public function setAdresseLivraison($adresseLivraison) { $this->adresseLivraison = $adresseLivraison; return $this; } /** - Get adresseLivraison * - @return string */ public function getAdresseLivraison() { return $this->adresseLivraison; } }

@HelpfulMan
Copy link
Author

my profileClientController

@HelpfulMan
Copy link
Author

container->get('security.context')->getToken()->getUser(); if (!is_object($user) || !$user instanceof UserInterface) { throw new AccessDeniedException('This user does not have access to this section.'); } ``` return $this->container->get('templating')->renderResponse('FOSUserBundle:Profile:show.html.'.$this->container->getParameter('fos_user.template.engine'), array('user' => $user)); } /** * Edit the user */ public function editAction(Request $request) { $user = $this->container->get('security.context')->getToken()->getUser(); if (!is_object($user) || !$user instanceof UserInterface) { throw new AccessDeniedException('This user does not have access to this section.'); } /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */ $dispatcher = $this->container->get('event_dispatcher'); $event = new GetResponseUserEvent($user, $request); $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_INITIALIZE, $event); if (null !== $event->getResponse()) { return $event->getResponse(); } /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */ $formFactory = $this->container->get('fos_user.profile.form.factory'); $form = $formFactory->createForm(); $form->setData($user); if ('POST' === $request->getMethod()) { $form->bind($request); if ($form->isValid()) { /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ $userManager = $this->container->get('fos_user.user_manager'); $event = new FormEvent($form, $request); $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_SUCCESS, $event); $userManager->updateUser($user); if (null === $response = $event->getResponse()) { $url = $this->container->get('router')->generate('fos_user_profile_show'); $response = new RedirectResponse($url); } $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_COMPLETED, new FilterUserResponseEvent($user, $request, $response)); return $response; } } return $this->container->get('templating')->renderResponse( 'pfeScoringBundle:Profile:editclient.html.'.$this->container->getParameter('fos_user.template.engine'), array('form' => $form->createView()) ); } ``` }

@HelpfulMan
Copy link
Author

here my form

@HelpfulMan
Copy link
Author

class = $class; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('NomClient') ->add('PrenomClient') ->add('AdresseLivraison') ->add('Telephone') ; } public function getName() { return 'pfe_Client_profile'; } /** * Builds the embedded form representing the user. * * @param FormBuilderInterface $builder * @param array $options */ protected function buildUserForm(FormBuilderInterface $builder, array $options) { $builder ->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle')) ->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle')) ; } ``` }

@HelpfulMan
Copy link
Author

my routing.yml & sevices.yml

@HelpfulMan
Copy link
Author

pfe_scoring_homepage:
pattern: /hello/{name}
defaults: { _controller: pfeScoringBundle:Default:index }

Client_registration:
pattern: /register/Client
defaults: { _controller: pfeScoringBundle:RegistrationClient:register }

Client_profile:
pattern: /edit/Client
defaults: { _controller: pfeScoringBundle:ProfileClient:edit}

@HelpfulMan
Copy link
Author

parameters:

pfe_scoring.example.class: pfe\ScoringBundle\Example

services:

pfe_scoring.example:

class: %pfe_scoring.example.class%

arguments: [@service_id, "plain_value", %parameter%]

pfe_Client.registration.form.type:
class: pfe\ScoringBundle\Form\Type\RegistrationClientFormType
arguments: [%fos_user.model.user.class%]
tags:
- { name: form.type, alias: pfe_Client_registration }

pfe_Client.profile.form.type:
class: pfe\ScoringBundle\Form\Type\ProfileClientFormType
arguments: [%fos_user.model.user.class%]
tags:
- { name: form.type, alias: pfe_Client_profile }

@HelpfulMan
Copy link
Author

could someone plz help me

@HelpfulMan
Copy link
Author

i get this Message

The form's view data is expected to be of type scalar, array or an instance of \ArrayAccess, but is an instance of class pfe\ScoringBundle\Entity\Client. You can avoid this error by setting the "data_class" option to "pfe\ScoringBundle\Entity\Client" or by adding a view transformer that transforms an instance of class pfe\ScoringBundle\Entity\Client to scalar, array or an instance of \ArrayAccess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant